Skip to content

Commit 0c90250

Browse files
committed
Syntax.
1 parent 555726a commit 0c90250

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

src/ProjectTemplates/scripts/Test-Template.psm1

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,29 +99,35 @@ function Test-Template {
9999
}
100100
}
101101

102+
103+
# Always set $packsDir before any use
104+
$packsDir = "$PSScriptRoot/.dotnet/packs/Microsoft.AspNetCore.App.Ref"
105+
102106
Write-Verbose "Patching Microsoft.AspNetCore.App";
103107

104108
# [dll check] 1) Check Microsoft.AspNetCore.Diagnostics.dll in PSScriptRoot before patching
105109
$psScriptDiagnosticsDll = "$PSScriptRoot/.dotnet/shared/Microsoft.AspNetCore.App/10.0.0-dev/Microsoft.AspNetCore.Diagnostics.dll";
106110
Check-DiagnosticsDll -Path $psScriptDiagnosticsDll -Description "1) PSScriptRoot Microsoft.AspNetCore.Diagnostics.dll before patching";
107111

108112
# 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";
113+
if (Test-Path $packsDir) {
114+
Get-ChildItem $packsDir -Directory | Remove-Item -Recurse -Force -ErrorAction Ignore
115+
Write-Verbose "Removed all existing reference pack versions from: $packsDir"
116+
}
111117

112118
# Check if dev version of reference assemblies exist in the runtime zip
113-
$devRefAssembliesSource = "$PSScriptRoot/.runtime/ref/Microsoft.AspNetCore.App";
119+
$devRefAssembliesSource = "$PSScriptRoot/.runtime/ref/Microsoft.AspNetCore.App"
114120
if (Test-Path $devRefAssembliesSource) {
115-
Write-Verbose "Found dev reference assemblies in runtime zip at: $devRefAssembliesSource";
116-
$devRefPackDir = "$packsDir/10.0.0-dev";
121+
Write-Verbose "Found dev reference assemblies in runtime zip at: $devRefAssembliesSource"
122+
$devRefPackDir = "$packsDir/10.0.0-dev"
117123
# Remove any existing dev reference pack directory first
118124
if (Test-Path $devRefPackDir) {
119-
Remove-Item -Path $devRefPackDir -Recurse -Force -ErrorAction Ignore;
125+
Remove-Item -Path $devRefPackDir -Recurse -Force -ErrorAction Ignore
120126
}
121-
New-Item -Path $devRefPackDir -ItemType Directory -Force | Out-Null;
127+
New-Item -Path $devRefPackDir -ItemType Directory -Force | Out-Null
122128
# 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";
129+
Copy-Item -Path "$devRefAssembliesSource/*" -Destination $devRefPackDir -Recurse -Force
130+
Write-Verbose "Successfully copied dev reference assemblies to $devRefPackDir"
125131
}
126132
if (-not (Check-DiagnosticsDll -Path $artifactsDiagnosticsDll -Description "3) Artifacts Microsoft.AspNetCore.Diagnostics.dll")) {
127133
# Try alternative location
@@ -236,7 +242,6 @@ function Test-Template {
236242
Write-Verbose "=== PATCHING REFERENCE ASSEMBLIES ==="
237243

238244
# Find the reference pack directory
239-
$packsDir = "$PSScriptRoot/.dotnet/packs/Microsoft.AspNetCore.App.Ref"
240245
if (Test-Path $packsDir)
241246
{
242247
Write-Verbose "Found reference packs directory: $packsDir"

0 commit comments

Comments
 (0)