Skip to content

Commit b35f0c8

Browse files
committed
Patch packs, so that they are same as shared.
1 parent 2611b48 commit b35f0c8

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

src/ProjectTemplates/scripts/Test-Template.psm1

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,65 @@ function Test-Template {
219219
Write-Warning "[dll check] Dev runtime folder not found at $devRuntimePath";
220220
}
221221

222+
# ===== PATCH REFERENCE ASSEMBLIES =====
223+
Write-Verbose "=== PATCHING REFERENCE ASSEMBLIES ===";
224+
225+
# Find the reference pack directory
226+
$packsDir = "$PSScriptRoot/.dotnet/packs/Microsoft.AspNetCore.App.Ref";
227+
if (Test-Path $packsDir) {
228+
Write-Verbose "Found reference packs directory: $packsDir";
229+
230+
# List existing reference pack versions
231+
$existingRefPacks = Get-ChildItem $packsDir -ErrorAction SilentlyContinue;
232+
if ($existingRefPacks) {
233+
Write-Verbose "Existing reference pack versions: $($existingRefPacks.Name -join ', ')";
234+
235+
# Check if dev version of reference assemblies exist in the runtime zip
236+
$devRefAssembliesSource = "$PSScriptRoot/.runtime/ref/Microsoft.AspNetCore.App";
237+
if (Test-Path $devRefAssembliesSource) {
238+
Write-Verbose "Found dev reference assemblies in runtime zip at: $devRefAssembliesSource";
239+
240+
# Create dev version reference pack directory
241+
$devRefPackDir = "$packsDir/10.0.0-dev";
242+
New-Item -Path $devRefPackDir -ItemType Directory -Force | Out-Null;
243+
244+
# Copy reference assemblies structure
245+
Write-Verbose "Copying dev reference assemblies to: $devRefPackDir";
246+
Copy-Item -Path "$devRefAssembliesSource/*" -Destination $devRefPackDir -Recurse -Force;
247+
248+
Write-Verbose "Successfully created dev reference pack at $devRefPackDir";
249+
250+
# [dll check] 5) Check reference assembly
251+
$devRefDiagnosticsDll = "$devRefPackDir/ref/net10.0/Microsoft.AspNetCore.Diagnostics.dll";
252+
Check-DiagnosticsDll -Path $devRefDiagnosticsDll -Description "5) Dev reference Microsoft.AspNetCore.Diagnostics.dll";
253+
} else {
254+
Write-Warning "No dev reference assemblies found in runtime zip - reference assemblies not patched!";
255+
256+
# Alternative: try to copy from the latest preview version and replace specific DLLs
257+
$latestRefPack = $existingRefPacks | Sort-Object Name -Descending | Select-Object -First 1;
258+
if ($latestRefPack) {
259+
Write-Verbose "Attempting to create dev reference pack based on: $($latestRefPack.Name)";
260+
$devRefPackDir = "$packsDir/10.0.0-dev";
261+
262+
# Copy the latest reference pack as base
263+
Copy-Item -Path $latestRefPack.FullName -Destination $devRefPackDir -Recurse -Force;
264+
265+
# Replace specific reference DLLs with runtime DLLs (not ideal but might work)
266+
$runtimeDiagnosticsDll = "$PSScriptRoot/.dotnet/shared/Microsoft.AspNetCore.App/10.0.0-dev/Microsoft.AspNetCore.Diagnostics.dll";
267+
$refDiagnosticsDll = "$devRefPackDir/ref/net10.0/Microsoft.AspNetCore.Diagnostics.dll";
268+
269+
if ((Test-Path $runtimeDiagnosticsDll) -and (Test-Path (Split-Path $refDiagnosticsDll))) {
270+
Copy-Item -Path $runtimeDiagnosticsDll -Destination $refDiagnosticsDll -Force;
271+
Write-Verbose "Replaced reference Microsoft.AspNetCore.Diagnostics.dll with runtime version";
272+
Check-DiagnosticsDll -Path $refDiagnosticsDll -Description "5) Patched reference Microsoft.AspNetCore.Diagnostics.dll";
273+
}
274+
}
275+
}
276+
}
277+
} else {
278+
Write-Warning "Reference packs directory not found at $packsDir";
279+
}
280+
222281
Write-Verbose "=== SETTING UP ENVIRONMENT ==="
223282
Write-Verbose "Setting DOTNET_ROOT to: $PSScriptRoot/.dotnet"
224283
$env:DOTNET_ROOT = "$PSScriptRoot/.dotnet";

0 commit comments

Comments
 (0)