Skip to content

Commit ac7f436

Browse files
committed
Remove contents of packs before patching it + upload to artifacts
1 parent b35f0c8 commit ac7f436

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

src/ProjectTemplates/scripts/Test-Template.psm1

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,24 @@ function Test-Template {
105105
$psScriptDiagnosticsDll = "$PSScriptRoot/.dotnet/shared/Microsoft.AspNetCore.App/10.0.0-dev/Microsoft.AspNetCore.Diagnostics.dll";
106106
Check-DiagnosticsDll -Path $psScriptDiagnosticsDll -Description "1) PSScriptRoot Microsoft.AspNetCore.Diagnostics.dll before patching";
107107

108-
$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" };
109-
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")) {
108+
# Remove all existing subdirectories (old versions)
109+
Get-ChildItem $packsDir -Directory | Remove-Item -Recurse -Force -ErrorAction Ignore;
110+
Write-Verbose "Removed all existing reference pack versions from: $packsDir";
111+
112+
# Check if dev version of reference assemblies exist in the runtime zip
113+
$devRefAssembliesSource = "$PSScriptRoot/.runtime/ref/Microsoft.AspNetCore.App";
114+
if (Test-Path $devRefAssembliesSource) {
115+
Write-Verbose "Found dev reference assemblies in runtime zip at: $devRefAssembliesSource";
116+
$devRefPackDir = "$packsDir/10.0.0-dev";
117+
# Remove any existing dev reference pack directory first
118+
if (Test-Path $devRefPackDir) {
119+
Remove-Item -Path $devRefPackDir -Recurse -Force -ErrorAction Ignore;
120+
}
121+
New-Item -Path $devRefPackDir -ItemType Directory -Force | Out-Null;
122+
# Copy the entire structure from the dev ref assemblies source
123+
Copy-Item -Path "$devRefAssembliesSource/*" -Destination $devRefPackDir -Recurse -Force;
124+
Write-Verbose "Successfully copied dev reference assemblies to $devRefPackDir";
125+
}
114126
# Try alternative location
115127
$artifactsDiagnosticsDll2 = "$PSScriptRoot/../../../artifacts/packages/$Configuration/Shipping/Microsoft.AspNetCore.Diagnostics.$TargetFramework.*.nupkg";
116128
$artifactsNupkg = Get-ChildItem $artifactsDiagnosticsDll2 -ErrorAction SilentlyContinue | Select-Object -First 1;
@@ -250,6 +262,13 @@ function Test-Template {
250262
# [dll check] 5) Check reference assembly
251263
$devRefDiagnosticsDll = "$devRefPackDir/ref/net10.0/Microsoft.AspNetCore.Diagnostics.dll";
252264
Check-DiagnosticsDll -Path $devRefDiagnosticsDll -Description "5) Dev reference Microsoft.AspNetCore.Diagnostics.dll";
265+
266+
# Upload the packs directory to CI artifacts for analysis
267+
if (Test-Path "$PSScriptRoot/.dotnet/packs") {
268+
$packsUploadPath = "$PSScriptRoot/.dotnet/packs";
269+
Write-Verbose "Uploading packs directory to CI artifacts: $packsUploadPath";
270+
Write-Host "##vso[artifact.upload containerfolder=packs-after;artifactname=packs-after]$packsUploadPath";
271+
}
253272
} else {
254273
Write-Warning "No dev reference assemblies found in runtime zip - reference assemblies not patched!";
255274

0 commit comments

Comments
 (0)