Skip to content

Commit f730fef

Browse files
committed
More size checks.
1 parent a680621 commit f730fef

File tree

1 file changed

+46
-6
lines changed

1 file changed

+46
-6
lines changed

src/ProjectTemplates/scripts/Test-Template.psm1

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,22 @@
44
Set-StrictMode -Version 2
55
$ErrorActionPreference = 'Stop'
66

7+
function Check-DiagnosticsDll {
8+
param(
9+
[string]$Path,
10+
[string]$Description
11+
)
12+
13+
if (Test-Path $Path) {
14+
$fileInfo = Get-Item $Path;
15+
Write-Verbose "[dll check] $Description - found - Size: $($fileInfo.Length) bytes, Modified: $($fileInfo.LastWriteTime)";
16+
return $true;
17+
} else {
18+
Write-Verbose "[dll check] $Description - not found at $Path";
19+
return $false;
20+
}
21+
}
22+
723
function Test-Template {
824
[CmdletBinding()]
925
param (
@@ -84,8 +100,27 @@ function Test-Template {
84100
}
85101

86102
Write-Verbose "Patching Microsoft.AspNetCore.App";
103+
104+
# [dll check] 1) Check Microsoft.AspNetCore.Diagnostics.dll in PSScriptRoot before patching
105+
$psScriptDiagnosticsDll = "$PSScriptRoot/.dotnet/shared/Microsoft.AspNetCore.App/10.0.0-dev/Microsoft.AspNetCore.Diagnostics.dll";
106+
Check-DiagnosticsDll -Path $psScriptDiagnosticsDll -Description "1) PSScriptRoot Microsoft.AspNetCore.Diagnostics.dll before patching";
107+
87108
$builtRuntime = Resolve-Path "$PSScriptRoot/../../../artifacts/packages/$Configuration/Shipping/aspnetcore-runtime-*-dev-win-x64.zip" | Where-Object { $_ -match "aspnetcore-runtime-[0-9.]+-dev-win-x64.zip" };
88109
Write-Verbose "Built runtime package: $builtRuntime";
110+
111+
# [dll check] 3) Check Microsoft.AspNetCore.Diagnostics.dll in artifacts
112+
$artifactsDiagnosticsDll = "$PSScriptRoot/../../../artifacts/bin/Microsoft.AspNetCore.Diagnostics/$Configuration/$TargetFramework/Microsoft.AspNetCore.Diagnostics.dll";
113+
if (-not (Check-DiagnosticsDll -Path $artifactsDiagnosticsDll -Description "3) Artifacts Microsoft.AspNetCore.Diagnostics.dll")) {
114+
# Try alternative location
115+
$artifactsDiagnosticsDll2 = "$PSScriptRoot/../../../artifacts/packages/$Configuration/Shipping/Microsoft.AspNetCore.Diagnostics.$TargetFramework.*.nupkg";
116+
$artifactsNupkg = Get-ChildItem $artifactsDiagnosticsDll2 -ErrorAction SilentlyContinue | Select-Object -First 1;
117+
if ($artifactsNupkg) {
118+
Write-Verbose "[dll check] Found Microsoft.AspNetCore.Diagnostics nupkg: $($artifactsNupkg.FullName)";
119+
} else {
120+
Write-Verbose "[dll check] No Microsoft.AspNetCore.Diagnostics nupkg found in artifacts";
121+
}
122+
}
123+
89124
Write-Verbose "Patching Microsoft.AspNetCore.App from $builtRuntime";
90125
Remove-Item "$PSScriptRoot/.runtime" -Recurse -ErrorAction Ignore;
91126
Expand-Archive -Path $builtRuntime -DestinationPath "$PSScriptRoot/.runtime" -Force;
@@ -95,6 +130,12 @@ function Test-Template {
95130
Get-ChildItem "$PSScriptRoot/.runtime/shared/Microsoft.AspNetCore.App" | ForEach-Object { Write-Verbose " $($_.Name)" }
96131
}
97132

133+
# [dll check] 2) Check Microsoft.AspNetCore.Diagnostics.dll in unpacked zip contents
134+
$unpackedDiagnosticsDll = "$PSScriptRoot/.runtime/shared/Microsoft.AspNetCore.App/10.0.0-dev/Microsoft.AspNetCore.Diagnostics.dll";
135+
if (-not (Check-DiagnosticsDll -Path $unpackedDiagnosticsDll -Description "2) Unpacked Microsoft.AspNetCore.Diagnostics.dll")) {
136+
Write-Warning "[dll check] Critical: Unpacked Microsoft.AspNetCore.Diagnostics.dll not found!";
137+
}
138+
98139
Write-Verbose "Removing ALL existing ASP.NET Core runtimes from local .dotnet...";
99140
try {
100141
$aspNetCoreRuntimePath = "$PSScriptRoot/.dotnet/shared/Microsoft.AspNetCore.App";
@@ -145,17 +186,16 @@ function Test-Template {
145186

146187
# Verify critical files were patched correctly
147188
Write-Verbose "Verifying patched runtime files...";
189+
190+
# [dll check] 4) Check Microsoft.AspNetCore.Diagnostics.dll after patching (existing check)
148191
$devRuntimePath = "$PSScriptRoot/.dotnet/shared/Microsoft.AspNetCore.App/10.0.0-dev";
149192
if (Test-Path $devRuntimePath) {
150193
$diagnosticsDll = "$devRuntimePath/Microsoft.AspNetCore.Diagnostics.dll";
151-
if (Test-Path $diagnosticsDll) {
152-
$fileInfo = Get-Item $diagnosticsDll;
153-
Write-Verbose "Microsoft.AspNetCore.Diagnostics.dll found - Size: $($fileInfo.Length) bytes, Modified: $($fileInfo.LastWriteTime)";
154-
} else {
155-
Write-Warning "Microsoft.AspNetCore.Diagnostics.dll not found in patched runtime!";
194+
if (-not (Check-DiagnosticsDll -Path $diagnosticsDll -Description "4) Microsoft.AspNetCore.Diagnostics.dll after patching")) {
195+
Write-Warning "[dll check] Critical: Microsoft.AspNetCore.Diagnostics.dll not found in patched runtime!";
156196
}
157197
} else {
158-
Write-Warning "Dev runtime folder not found at $devRuntimePath";
198+
Write-Warning "[dll check] Dev runtime folder not found at $devRuntimePath";
159199
}
160200

161201
Write-Verbose "=== SETTING UP ENVIRONMENT ==="

0 commit comments

Comments
 (0)