Skip to content

Commit 03d35ca

Browse files
committed
Verify patching.
1 parent a1939c1 commit 03d35ca

File tree

1 file changed

+37
-2
lines changed

1 file changed

+37
-2
lines changed

src/ProjectTemplates/scripts/Test-Template.psm1

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,21 +96,56 @@ function Test-Template {
9696
}
9797

9898
Write-Verbose "Removing existing dev runtimes from local .dotnet...";
99-
Remove-Item "$PSScriptRoot/.dotnet/shared/Microsoft.AspNetCore.App/*-dev" -Recurse -ErrorAction Ignore;
99+
try {
100+
$devRuntimes = Get-ChildItem "$PSScriptRoot/.dotnet/shared/Microsoft.AspNetCore.App/*-dev" -ErrorAction SilentlyContinue;
101+
if ($devRuntimes) {
102+
Write-Verbose "Found existing dev runtimes to remove: $($devRuntimes.Name -join ', ')";
103+
Remove-Item "$PSScriptRoot/.dotnet/shared/Microsoft.AspNetCore.App/*-dev" -Recurse -Force -ErrorAction Stop;
104+
Write-Verbose "Successfully removed existing dev runtimes";
105+
} else {
106+
Write-Verbose "No existing dev runtimes found to remove";
107+
}
108+
}
109+
catch {
110+
Write-Warning "Failed to remove existing dev runtimes: $($_.Exception.Message)";
111+
# Continue anyway - this might not be critical
112+
}
100113

101114
Write-Verbose "Before patching - local .dotnet ASP.NET Core runtimes:";
102115
if (Test-Path "$PSScriptRoot/.dotnet/shared/Microsoft.AspNetCore.App") {
103116
Get-ChildItem "$PSScriptRoot/.dotnet/shared/Microsoft.AspNetCore.App" | ForEach-Object { Write-Verbose " $($_.Name)" }
104117
}
105118

106119
Write-Verbose "Copying $PSScriptRoot/.runtime/shared/Microsoft.AspNetCore.App to $PSScriptRoot/.dotnet/shared";
107-
Copy-Item -Path "$PSScriptRoot/.runtime/shared/Microsoft.AspNetCore.App" -Destination "$PSScriptRoot/.dotnet/shared" -Recurse -Force;
120+
try {
121+
Copy-Item -Path "$PSScriptRoot/.runtime/shared/Microsoft.AspNetCore.App" -Destination "$PSScriptRoot/.dotnet/shared" -Recurse -Force -ErrorAction Stop;
122+
Write-Verbose "Runtime copy completed successfully";
123+
}
124+
catch {
125+
Write-Error "Failed to copy runtime: $($_.Exception.Message)";
126+
throw;
127+
}
108128

109129
Write-Verbose "After patching - local .dotnet ASP.NET Core runtimes:";
110130
if (Test-Path "$PSScriptRoot/.dotnet/shared/Microsoft.AspNetCore.App") {
111131
Get-ChildItem "$PSScriptRoot/.dotnet/shared/Microsoft.AspNetCore.App" | ForEach-Object { Write-Verbose " $($_.Name)" }
112132
}
113133

134+
# Verify critical files were patched correctly
135+
Write-Verbose "Verifying patched runtime files...";
136+
$devRuntimePath = "$PSScriptRoot/.dotnet/shared/Microsoft.AspNetCore.App/10.0.0-dev";
137+
if (Test-Path $devRuntimePath) {
138+
$diagnosticsDll = "$devRuntimePath/Microsoft.AspNetCore.Diagnostics.dll";
139+
if (Test-Path $diagnosticsDll) {
140+
$fileInfo = Get-Item $diagnosticsDll;
141+
Write-Verbose "Microsoft.AspNetCore.Diagnostics.dll found - Size: $($fileInfo.Length) bytes, Modified: $($fileInfo.LastWriteTime)";
142+
} else {
143+
Write-Warning "Microsoft.AspNetCore.Diagnostics.dll not found in patched runtime!";
144+
}
145+
} else {
146+
Write-Warning "Dev runtime folder not found at $devRuntimePath";
147+
}
148+
114149
Write-Verbose "=== SETTING UP ENVIRONMENT ==="
115150
Write-Verbose "Setting DOTNET_ROOT to: $PSScriptRoot/.dotnet"
116151
$env:DOTNET_ROOT = "$PSScriptRoot/.dotnet";

0 commit comments

Comments
 (0)