From a4bbcb4bd9e78f69093eb7085115ac2dda03322d Mon Sep 17 00:00:00 2001
From: Jamie Chapman <104535858+bilbospocketses@users.noreply.github.com>
Date: Sat, 18 Jul 2026 17:47:37 -0400
Subject: [PATCH] fix: resolve WebView2 version from the csproj (single source
of truth) + bump to 1.0.4078.44
The WebView2 version was hardcoded in src/Tiny11.WebView2.psm1 ($PinnedVersion =
1.0.2535.41) AND declared in the launcher csproj. Dependabot bumps only the csproj, so
the module kept resolving the OLD NuGet path -- the "finds the NuGet-restored DLLs"
Pester integration test then failed (why WebView2 bump PR #39 was red).
- Get-Tiny11WebView2Version reads the version from the launcher csproj's
PackageReference, so the module always follows the csproj. No hardcoded copy, no
drift, no second edit on a bump.
- Tests derive the expected version the same way (were hardcoded to 1.0.2535.41),
plus coverage for the new resolver.
- Applied the bump that exposed this: Microsoft.Web.WebView2 -> 1.0.4078.44 (supersedes #39).
Verified locally: dotnet build clean; all 14 WebView2 Pester tests pass, including the
integration test that was failing.
---
launcher/tiny11options.Launcher.csproj | 9 ++---
src/Tiny11.WebView2.psm1 | 30 +++++++++++++---
tests/Tiny11.WebView2.Tests.ps1 | 49 ++++++++++++++++++++++----
3 files changed, 73 insertions(+), 15 deletions(-)
diff --git a/launcher/tiny11options.Launcher.csproj b/launcher/tiny11options.Launcher.csproj
index 342aec7..8a799c3 100644
--- a/launcher/tiny11options.Launcher.csproj
+++ b/launcher/tiny11options.Launcher.csproj
@@ -110,10 +110,11 @@
-
+ via the package's build/native targets. This is the
+ SINGLE SOURCE OF TRUTH for the WebView2 version: src/Tiny11.WebView2.psm1
+ resolves the SDK path from it (Get-Tiny11WebView2Version), so a routine
+ Dependabot bump flows through with no second edit. -->
+
diff --git a/src/Tiny11.WebView2.psm1 b/src/Tiny11.WebView2.psm1
index 6cb982f..224a3c6 100644
--- a/src/Tiny11.WebView2.psm1
+++ b/src/Tiny11.WebView2.psm1
@@ -1,7 +1,5 @@
Set-StrictMode -Version Latest
-$PinnedVersion = '1.0.2535.41'
-
# Minimum sizes must match the XAML MinWidth/MinHeight below; clamping prevents loading a
# stale settings.json from a previous build whose minimums were smaller.
$script:MinWindowWidth = 1000
@@ -33,18 +31,40 @@ function Save-Tiny11UserSettings {
[System.IO.File]::WriteAllText($path, $json, [System.Text.UTF8Encoding]::new($false))
}
+function Get-Tiny11WebView2Version {
+ # The launcher csproj's is the single source of truth for the
+ # WebView2 version. Reading it here (instead of hardcoding a copy) means a routine
+ # Dependabot bump to the csproj flows through automatically -- the SDK-path
+ # resolution below follows it with no second edit, so the two never drift.
+ [CmdletBinding()]
+ param([string]$CsprojPath)
+ if (-not $CsprojPath) {
+ $CsprojPath = Join-Path $PSScriptRoot '..\launcher\tiny11options.Launcher.csproj'
+ }
+ if (-not (Test-Path $CsprojPath)) {
+ throw "Cannot resolve the WebView2 version: launcher csproj not found at $CsprojPath."
+ }
+ $content = Get-Content -Path $CsprojPath -Raw
+ if ($content -match ' in $CsprojPath."
+}
+
function Get-Tiny11WebView2SdkPath {
[CmdletBinding()]
- param([string]$NugetPackagesRoot)
+ param([string]$NugetPackagesRoot, [string]$Version)
# Resolve the NuGet global packages folder. NUGET_PACKAGES env var overrides
# the default per Microsoft's NuGet docs on global-packages-and-cache-folders.
if (-not $NugetPackagesRoot) {
$NugetPackagesRoot = if ($env:NUGET_PACKAGES) { $env:NUGET_PACKAGES } else { Join-Path $env:USERPROFILE '.nuget\packages' }
}
+ # Version tracks the csproj (single source of truth) unless the caller overrides it.
+ if (-not $Version) { $Version = Get-Tiny11WebView2Version }
# NuGet caches as \\\... -- package id is lowercased on disk.
# Managed wrappers live under lib\\; net462 is the right TFM for PowerShell 5.1
# (.NET Framework 4.x WPF host). Native loader lives under runtimes\win-x64\native\.
- $pkgDir = Join-Path $NugetPackagesRoot "microsoft.web.webview2\$PinnedVersion"
+ $pkgDir = Join-Path $NugetPackagesRoot "microsoft.web.webview2\$Version"
[pscustomobject]@{
VersionDir = $pkgDir
CoreDll = Join-Path $pkgDir 'lib\net462\Microsoft.Web.WebView2.Core.dll'
@@ -193,4 +213,4 @@ function Show-Tiny11Wizard {
[void]$window.ShowDialog()
}
-Export-ModuleMember -Function Get-Tiny11WebView2SdkPath, Test-Tiny11WebView2SdkPresent, Test-Tiny11WebView2RuntimeInstalled, Show-Tiny11Wizard, Set-Tiny11WizardWindow, Get-Tiny11WizardWindow, Get-Tiny11WizardWebView, Get-Tiny11UserSettingsPath, Get-Tiny11UserSettings, Save-Tiny11UserSettings
+Export-ModuleMember -Function Get-Tiny11WebView2Version, Get-Tiny11WebView2SdkPath, Test-Tiny11WebView2SdkPresent, Test-Tiny11WebView2RuntimeInstalled, Show-Tiny11Wizard, Set-Tiny11WizardWindow, Get-Tiny11WizardWindow, Get-Tiny11WizardWebView, Get-Tiny11UserSettingsPath, Get-Tiny11UserSettings, Save-Tiny11UserSettings
diff --git a/tests/Tiny11.WebView2.Tests.ps1 b/tests/Tiny11.WebView2.Tests.ps1
index c17fa33..e7f5211 100644
--- a/tests/Tiny11.WebView2.Tests.ps1
+++ b/tests/Tiny11.WebView2.Tests.ps1
@@ -2,19 +2,52 @@ Set-StrictMode -Version 3.0
Import-Module "$PSScriptRoot/Tiny11.TestHelpers.psm1" -Force
Import-Tiny11Module -Name 'Tiny11.WebView2'
+BeforeAll {
+ # The WebView2 version is sourced from the launcher csproj (single source of
+ # truth); derive the expected value the same way so these tests never hardcode a
+ # version that drifts when Dependabot bumps the csproj.
+ $script:ver = Get-Tiny11WebView2Version
+}
+
+Describe "Get-Tiny11WebView2Version" {
+ It "reads the Microsoft.Web.WebView2 version from the launcher csproj" {
+ $script:ver | Should -Match '^\d+\.\d+\.\d+\.\d+$'
+ }
+ It "honors an explicit -CsprojPath override" {
+ $tmp = New-TempScratchDir
+ try {
+ $csproj = Join-Path $tmp 'x.csproj'
+ Set-Content -Path $csproj -Value ''
+ Get-Tiny11WebView2Version -CsprojPath $csproj | Should -Be '9.9.9.9'
+ } finally {
+ Remove-TempScratchDir -Path $tmp
+ }
+ }
+ It "throws when the csproj has no WebView2 PackageReference" {
+ $tmp = New-TempScratchDir
+ try {
+ $csproj = Join-Path $tmp 'x.csproj'
+ Set-Content -Path $csproj -Value ''
+ { Get-Tiny11WebView2Version -CsprojPath $csproj } | Should -Throw -ExpectedMessage '*no Microsoft.Web.WebView2*'
+ } finally {
+ Remove-TempScratchDir -Path $tmp
+ }
+ }
+}
+
Describe "Get-Tiny11WebView2SdkPath" {
It "returns paths under the NuGet packages cache for microsoft.web.webview2/" {
$r = Get-Tiny11WebView2SdkPath
$r.CoreDll | Should -Match 'lib[\\/]net462[\\/]Microsoft\.Web\.WebView2\.Core\.dll$'
$r.WpfDll | Should -Match 'lib[\\/]net462[\\/]Microsoft\.Web\.WebView2\.Wpf\.dll$'
$r.NativeDll | Should -Match 'runtimes[\\/]win-x64[\\/]native[\\/]WebView2Loader\.dll$'
- $r.VersionDir | Should -Match 'microsoft\.web\.webview2[\\/]1\.0\.2535\.41$'
+ $r.VersionDir | Should -Match "microsoft\.web\.webview2[\\/]$([regex]::Escape($script:ver))$"
}
It "honors -NugetPackagesRoot override" {
$tmp = New-TempScratchDir
try {
$r = Get-Tiny11WebView2SdkPath -NugetPackagesRoot $tmp
- $r.CoreDll | Should -BeLike "$tmp*microsoft.web.webview2*1.0.2535.41*lib*net462*Microsoft.Web.WebView2.Core.dll"
+ $r.CoreDll | Should -BeLike "$tmp*microsoft.web.webview2*$script:ver*lib*net462*Microsoft.Web.WebView2.Core.dll"
} finally {
Remove-TempScratchDir -Path $tmp
}
@@ -25,20 +58,24 @@ Describe "Get-Tiny11WebView2SdkPath" {
try {
$env:NUGET_PACKAGES = $tmp
$r = Get-Tiny11WebView2SdkPath
- $r.CoreDll | Should -BeLike "$tmp*microsoft.web.webview2*1.0.2535.41*lib*net462*Microsoft.Web.WebView2.Core.dll"
+ $r.CoreDll | Should -BeLike "$tmp*microsoft.web.webview2*$script:ver*lib*net462*Microsoft.Web.WebView2.Core.dll"
} finally {
$env:NUGET_PACKAGES = $original
Remove-TempScratchDir -Path $tmp
}
}
+ It "honors an explicit -Version override" {
+ $r = Get-Tiny11WebView2SdkPath -NugetPackagesRoot 'C:\pkgs' -Version '1.2.3.4'
+ $r.VersionDir | Should -BeLike '*microsoft.web.webview2*1.2.3.4'
+ }
}
Describe "Test-Tiny11WebView2SdkPresent" {
It "returns paths object when all 3 DLLs present" {
$tmp = New-TempScratchDir
try {
- $libDir = Join-Path $tmp 'microsoft.web.webview2\1.0.2535.41\lib\net462'
- $nativeDir = Join-Path $tmp 'microsoft.web.webview2\1.0.2535.41\runtimes\win-x64\native'
+ $libDir = Join-Path $tmp "microsoft.web.webview2\$script:ver\lib\net462"
+ $nativeDir = Join-Path $tmp "microsoft.web.webview2\$script:ver\runtimes\win-x64\native"
New-Item -ItemType Directory -Force -Path $libDir | Out-Null
New-Item -ItemType Directory -Force -Path $nativeDir | Out-Null
New-Item -ItemType File -Path (Join-Path $libDir 'Microsoft.Web.WebView2.Core.dll') -Force | Out-Null
@@ -71,7 +108,7 @@ Describe "Test-Tiny11WebView2SdkPresent" {
It "throws when only some DLLs are present" {
$tmp = New-TempScratchDir
try {
- $libDir = Join-Path $tmp 'microsoft.web.webview2\1.0.2535.41\lib\net462'
+ $libDir = Join-Path $tmp "microsoft.web.webview2\$script:ver\lib\net462"
New-Item -ItemType Directory -Force -Path $libDir | Out-Null
New-Item -ItemType File -Path (Join-Path $libDir 'Microsoft.Web.WebView2.Core.dll') -Force | Out-Null
{ Test-Tiny11WebView2SdkPresent -NugetPackagesRoot $tmp } | Should -Throw -ExpectedMessage '*WebView2 SDK DLL missing*'