mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-04-03 10:11:15 +02:00
fix(bundler): detect per-user webview2 installations (#3076)
Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
This commit is contained in:
@@ -219,7 +219,8 @@
|
||||
{{#if install_webview}}
|
||||
<!-- WebView2 -->
|
||||
<Property Id="WVRTINSTALLED">
|
||||
<RegistrySearch Id="WVRTInstalled" Root="HKLM" Key="SOFTWARE\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}" Name="pv" Type="raw" Win64="no"/>
|
||||
<RegistrySearch Id="WVRTInstalledSystem" Root="HKLM" Key="SOFTWARE\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}" Name="pv" Type="raw" Win64="no" />
|
||||
<RegistrySearch Id="WVRTInstalledUser" Root="HKCU" Key="SOFTWARE\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}" Name="pv" Type="raw"/>
|
||||
</Property>
|
||||
<CustomAction Id='DownloadAndInvokeBootstrapper' Directory="INSTALLDIR" Execute="deferred" ExeCommand='powershell.exe -NoProfile -windowstyle hidden Invoke-WebRequest -Uri "https://go.microsoft.com/fwlink/p/?LinkId=2124703" -OutFile "$env:TEMP\MicrosoftEdgeWebview2Setup.exe" ; & $env:TEMP\MicrosoftEdgeWebview2Setup.exe /install' Return='check'/>
|
||||
<InstallExecuteSequence>
|
||||
|
||||
@@ -271,25 +271,38 @@ fn get_version(command: &str, args: &[&str]) -> crate::Result<Option<String>> {
|
||||
|
||||
#[cfg(windows)]
|
||||
fn webview2_version() -> crate::Result<Option<String>> {
|
||||
// check 64bit machine-wide installation
|
||||
let output = Command::new("powershell")
|
||||
.args(&["-NoProfile", "-Command"])
|
||||
.arg("Get-ItemProperty -Path 'HKLM:\\SOFTWARE\\WOW6432Node\\Microsoft\\EdgeUpdate\\Clients\\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}' | ForEach-Object {$_.pv}")
|
||||
.output()?;
|
||||
let version = if output.status.success() {
|
||||
Some(String::from_utf8_lossy(&output.stdout).replace('\n', ""))
|
||||
} else {
|
||||
// check 32bit installation
|
||||
let output = Command::new("powershell")
|
||||
if output.status.success() {
|
||||
return Ok(Some(
|
||||
String::from_utf8_lossy(&output.stdout).replace('\n', ""),
|
||||
));
|
||||
}
|
||||
// check 32bit machine-wide installation
|
||||
let output = Command::new("powershell")
|
||||
.args(&["-NoProfile", "-Command"])
|
||||
.arg("Get-ItemProperty -Path 'HKLM:\\SOFTWARE\\Microsoft\\EdgeUpdate\\Clients\\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}' | ForEach-Object {$_.pv}")
|
||||
.output()?;
|
||||
if output.status.success() {
|
||||
Some(String::from_utf8_lossy(&output.stdout).replace('\n', ""))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
};
|
||||
Ok(version)
|
||||
if output.status.success() {
|
||||
return Ok(Some(
|
||||
String::from_utf8_lossy(&output.stdout).replace('\n', ""),
|
||||
));
|
||||
}
|
||||
// check user-wide installation
|
||||
let output = Command::new("powershell")
|
||||
.args(&["-NoProfile", "-Command"])
|
||||
.arg("Get-ItemProperty -Path 'HKCU:\\SOFTWARE\\Microsoft\\EdgeUpdate\\Clients\\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}' | ForEach-Object {$_.pv}")
|
||||
.output()?;
|
||||
if output.status.success() {
|
||||
return Ok(Some(
|
||||
String::from_utf8_lossy(&output.stdout).replace('\n', ""),
|
||||
));
|
||||
}
|
||||
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
|
||||
Reference in New Issue
Block a user