Skip to content

Commit

Permalink
Use path from registry key and string version
Browse files Browse the repository at this point in the history
  • Loading branch information
Legend-Master committed Aug 22, 2024
1 parent 039b5c2 commit 0b7e61f
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 30 deletions.
8 changes: 3 additions & 5 deletions core/tauri-config-schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2368,13 +2368,11 @@
]
},
"ensureWebview2Version": {
"description": "Ensure webview2 version to be newer than this major version,\n if the user's webview2 is older than this version,\n the installer will trigger a webview2 update",
"description": "Ensure webview2 version to be newer than this version,\n if the user's webview2 is older than this version,\n the installer will trigger a webview2 update",
"type": [
"integer",
"string",
"null"
],
"format": "uint16",
"minimum": 0.0
]
}
},
"additionalProperties": false
Expand Down
4 changes: 2 additions & 2 deletions core/tauri-utils/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -838,11 +838,11 @@ pub struct NsisConfig {
/// ```
#[serde(alias = "installer-hooks")]
pub installer_hooks: Option<PathBuf>,
/// Ensure webview2 version to be newer than this major version,
/// Ensure webview2 version to be newer than this version,
/// if the user's webview2 is older than this version,
/// the installer will trigger a webview2 update
#[serde(alias = "ensure-webview2-version")]
pub ensure_webview2_version: Option<u16>,
pub ensure_webview2_version: Option<String>,
}

/// Install modes for the Webview2 runtime.
Expand Down
4 changes: 2 additions & 2 deletions tooling/bundler/src/bundle/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,10 +457,10 @@ pub struct NsisSettings {
/// !macroend
/// ```
pub installer_hooks: Option<PathBuf>,
/// Ensure webview2 version to be newer than this major version,
/// Ensure webview2 version to be newer than this version,
/// if the user's webview2 is older than this version,
/// the installer will trigger a webview2 update
pub ensure_webview2_version: Option<u16>,
pub ensure_webview2_version: Option<String>,
}

/// The Custom Signing Command Settings for Windows exe
Expand Down
41 changes: 25 additions & 16 deletions tooling/bundler/src/bundle/windows/templates/installer.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ ${StrLoc}
!include "{{installer_hooks}}"
{{/if}}

!define WEBVIEW2APPGUID "{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}"

!define MANUFACTURER "{{manufacturer}}"
!define PRODUCTNAME "{{product_name}}"
!define VERSION "{{version}}"
Expand Down Expand Up @@ -494,14 +496,15 @@ SectionEnd
Section WebView2
; Check if Webview2 is already installed and skip this section
${If} ${RunningX64}
ReadRegStr $4 HKLM "SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}" "pv"
ReadRegStr $4 HKLM "SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate\Clients\${WEBVIEW2APPGUID}" "pv"
${Else}
ReadRegStr $4 HKLM "SOFTWARE\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}" "pv"
ReadRegStr $4 HKLM "SOFTWARE\Microsoft\EdgeUpdate\Clients\${WEBVIEW2APPGUID}" "pv"
${EndIf}
${If} $4 == ""
ReadRegStr $4 HKCU "SOFTWARE\Microsoft\EdgeUpdate\Clients\${WEBVIEW2APPGUID}" "pv"
${EndIf}
ReadRegStr $5 HKCU "SOFTWARE\Microsoft\EdgeUpdate\Clients\{F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}" "pv"

${If} $4 == ""
${AndIf} $5 == ""
; Webview2 installation
;
; Skip if updating
Expand Down Expand Up @@ -553,21 +556,27 @@ Section WebView2
${EndIf}
${Else}
!if "${MINIMUMWEBVIEW2VERSION}" != ""
${If} $4 != ""
${VersionCompare} "${MINIMUMWEBVIEW2VERSION}" "$4" $R0
${Else}
${VersionCompare} "${MINIMUMWEBVIEW2VERSION}" "$5" $R0
${EndIf}
${VersionCompare} "${MINIMUMWEBVIEW2VERSION}" "$4" $R0
${If} $R0 = 1
DetailPrint "$(installingWebview2)"
; Chromium updater docs: https://source.chromium.org/chromium/chromium/src/+/main:docs/updater/user_manual.md
; Modified from "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft EdgeWebView\ModifyPath"
ExecWait `"C:\Program Files (x86)\Microsoft\EdgeUpdate\MicrosoftEdgeUpdate.exe" /install appguid={F3017226-FE2A-4295-8BDF-00C3A9A7E4C5}&needsadmin=true` $1
${If} $1 = 0
DetailPrint "$(webview2InstallSuccess)"
${If} ${RunningX64}
ReadRegStr $R1 HKLM "SOFTWARE\WOW6432Node\Microsoft\EdgeUpdate" "path"
${Else}
DetailPrint "$(webview2InstallError)"
Abort "$(webview2AbortError)"
ReadRegStr $R1 HKLM "SOFTWARE\Microsoft\EdgeUpdate" "path"
${EndIf}
${If} $R1 == ""
ReadRegStr $R1 HKCU "SOFTWARE\Microsoft\EdgeUpdate" "path"
${EndIf}
${If} $R1 != ""
; Chromium updater docs: https://source.chromium.org/chromium/chromium/src/+/main:docs/updater/user_manual.md
; Modified from "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft EdgeWebView\ModifyPath"
ExecWait `"$R1" /install appguid=${WEBVIEW2APPGUID}&needsadmin=true` $1
${If} $1 = 0
DetailPrint "$(webview2InstallSuccess)"
${Else}
DetailPrint "$(webview2InstallError)"
Abort "$(webview2AbortError)"
${EndIf}
${EndIf}
${EndIf}
!endif
Expand Down
8 changes: 3 additions & 5 deletions tooling/cli/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2368,13 +2368,11 @@
]
},
"ensureWebview2Version": {
"description": "Ensure webview2 version to be newer than this major version,\n if the user's webview2 is older than this version,\n the installer will trigger a webview2 update",
"description": "Ensure webview2 version to be newer than this version,\n if the user's webview2 is older than this version,\n the installer will trigger a webview2 update",
"type": [
"integer",
"string",
"null"
],
"format": "uint16",
"minimum": 0.0
]
}
},
"additionalProperties": false
Expand Down

0 comments on commit 0b7e61f

Please sign in to comment.