Skip to content

Commit a680621

Browse files
committed
Make sure the old packs are gone before we start patching.
1 parent 562a306 commit a680621

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

src/ProjectTemplates/scripts/Test-Template.psm1

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,19 +95,31 @@ function Test-Template {
9595
Get-ChildItem "$PSScriptRoot/.runtime/shared/Microsoft.AspNetCore.App" | ForEach-Object { Write-Verbose " $($_.Name)" }
9696
}
9797

98-
Write-Verbose "Removing existing dev runtimes from local .dotnet...";
98+
Write-Verbose "Removing ALL existing ASP.NET Core runtimes from local .dotnet...";
9999
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";
100+
$aspNetCoreRuntimePath = "$PSScriptRoot/.dotnet/shared/Microsoft.AspNetCore.App";
101+
if (Test-Path $aspNetCoreRuntimePath) {
102+
$existingRuntimes = Get-ChildItem $aspNetCoreRuntimePath -ErrorAction SilentlyContinue;
103+
if ($existingRuntimes) {
104+
Write-Verbose "Found existing ASP.NET Core runtimes to remove: $($existingRuntimes.Name -join ', ')";
105+
Remove-Item $aspNetCoreRuntimePath -Recurse -Force -ErrorAction Stop;
106+
Write-Verbose "Successfully removed all existing ASP.NET Core runtimes";
107+
108+
# Recreate the directory
109+
New-Item -Path $aspNetCoreRuntimePath -ItemType Directory -Force | Out-Null;
110+
Write-Verbose "Recreated ASP.NET Core runtime directory";
111+
} else {
112+
Write-Verbose "No existing ASP.NET Core runtimes found to remove";
113+
}
105114
} else {
106-
Write-Verbose "No existing dev runtimes found to remove";
115+
Write-Verbose "ASP.NET Core runtime directory does not exist";
116+
# Create the directory
117+
New-Item -Path $aspNetCoreRuntimePath -ItemType Directory -Force | Out-Null;
118+
Write-Verbose "Created ASP.NET Core runtime directory";
107119
}
108120
}
109121
catch {
110-
Write-Warning "Failed to remove existing dev runtimes: $($_.Exception.Message)";
122+
Write-Warning "Failed to remove existing ASP.NET Core runtimes: $($_.Exception.Message)";
111123
# Continue anyway - this might not be critical
112124
}
113125

0 commit comments

Comments
 (0)