Skip to content

Commit 43c7434

Browse files
committed
Syntax...
1 parent ac7f436 commit 43c7434

File tree

1 file changed

+47
-37
lines changed

1 file changed

+47
-37
lines changed

src/ProjectTemplates/scripts/Test-Template.psm1

Lines changed: 47 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -232,69 +232,79 @@ function Test-Template {
232232
}
233233

234234
# ===== PATCH REFERENCE ASSEMBLIES =====
235-
Write-Verbose "=== PATCHING REFERENCE ASSEMBLIES ===";
235+
Write-Verbose "=== PATCHING REFERENCE ASSEMBLIES ==="
236236

237237
# Find the reference pack directory
238-
$packsDir = "$PSScriptRoot/.dotnet/packs/Microsoft.AspNetCore.App.Ref";
239-
if (Test-Path $packsDir) {
240-
Write-Verbose "Found reference packs directory: $packsDir";
238+
$packsDir = "$PSScriptRoot/.dotnet/packs/Microsoft.AspNetCore.App.Ref"
239+
if (Test-Path $packsDir)
240+
{
241+
Write-Verbose "Found reference packs directory: $packsDir"
241242

242243
# List existing reference pack versions
243-
$existingRefPacks = Get-ChildItem $packsDir -ErrorAction SilentlyContinue;
244-
if ($existingRefPacks) {
245-
Write-Verbose "Existing reference pack versions: $($existingRefPacks.Name -join ', ')";
244+
$existingRefPacks = Get-ChildItem $packsDir -ErrorAction SilentlyContinue
245+
if ($existingRefPacks)
246+
{
247+
Write-Verbose "Existing reference pack versions: $($existingRefPacks.Name -join ', ')"
246248

247249
# Check if dev version of reference assemblies exist in the runtime zip
248-
$devRefAssembliesSource = "$PSScriptRoot/.runtime/ref/Microsoft.AspNetCore.App";
249-
if (Test-Path $devRefAssembliesSource) {
250-
Write-Verbose "Found dev reference assemblies in runtime zip at: $devRefAssembliesSource";
250+
$devRefAssembliesSource = "$PSScriptRoot/.runtime/ref/Microsoft.AspNetCore.App"
251+
if (Test-Path $devRefAssembliesSource)
252+
{
253+
Write-Verbose "Found dev reference assemblies in runtime zip at: $devRefAssembliesSource"
251254

252255
# Create dev version reference pack directory
253-
$devRefPackDir = "$packsDir/10.0.0-dev";
254-
New-Item -Path $devRefPackDir -ItemType Directory -Force | Out-Null;
256+
$devRefPackDir = "$packsDir/10.0.0-dev"
257+
New-Item -Path $devRefPackDir -ItemType Directory -Force | Out-Null
255258

256259
# Copy reference assemblies structure
257-
Write-Verbose "Copying dev reference assemblies to: $devRefPackDir";
258-
Copy-Item -Path "$devRefAssembliesSource/*" -Destination $devRefPackDir -Recurse -Force;
260+
Write-Verbose "Copying dev reference assemblies to: $devRefPackDir"
261+
Copy-Item -Path "$devRefAssembliesSource/*" -Destination $devRefPackDir -Recurse -Force
259262

260-
Write-Verbose "Successfully created dev reference pack at $devRefPackDir";
263+
Write-Verbose "Successfully created dev reference pack at $devRefPackDir"
261264

262265
# [dll check] 5) Check reference assembly
263-
$devRefDiagnosticsDll = "$devRefPackDir/ref/net10.0/Microsoft.AspNetCore.Diagnostics.dll";
264-
Check-DiagnosticsDll -Path $devRefDiagnosticsDll -Description "5) Dev reference Microsoft.AspNetCore.Diagnostics.dll";
266+
$devRefDiagnosticsDll = "$devRefPackDir/ref/net10.0/Microsoft.AspNetCore.Diagnostics.dll"
267+
Check-DiagnosticsDll -Path $devRefDiagnosticsDll -Description "5) Dev reference Microsoft.AspNetCore.Diagnostics.dll"
265268

266269
# 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";
270+
if (Test-Path "$PSScriptRoot/.dotnet/packs")
271+
{
272+
$packsUploadPath = "$PSScriptRoot/.dotnet/packs"
273+
Write-Verbose "Uploading packs directory to CI artifacts: $packsUploadPath"
274+
Write-Host "##vso[artifact.upload containerfolder=packs-after;artifactname=packs-after]$packsUploadPath"
271275
}
272-
} else {
273-
Write-Warning "No dev reference assemblies found in runtime zip - reference assemblies not patched!";
276+
}
277+
else
278+
{
279+
Write-Warning "No dev reference assemblies found in runtime zip - reference assemblies not patched!"
274280

275281
# Alternative: try to copy from the latest preview version and replace specific DLLs
276-
$latestRefPack = $existingRefPacks | Sort-Object Name -Descending | Select-Object -First 1;
277-
if ($latestRefPack) {
278-
Write-Verbose "Attempting to create dev reference pack based on: $($latestRefPack.Name)";
279-
$devRefPackDir = "$packsDir/10.0.0-dev";
282+
$latestRefPack = $existingRefPacks | Sort-Object Name -Descending | Select-Object -First 1
283+
if ($latestRefPack)
284+
{
285+
Write-Verbose "Attempting to create dev reference pack based on: $($latestRefPack.Name)"
286+
$devRefPackDir = "$packsDir/10.0.0-dev"
280287

281288
# Copy the latest reference pack as base
282-
Copy-Item -Path $latestRefPack.FullName -Destination $devRefPackDir -Recurse -Force;
289+
Copy-Item -Path $latestRefPack.FullName -Destination $devRefPackDir -Recurse -Force
283290

284291
# Replace specific reference DLLs with runtime DLLs (not ideal but might work)
285-
$runtimeDiagnosticsDll = "$PSScriptRoot/.dotnet/shared/Microsoft.AspNetCore.App/10.0.0-dev/Microsoft.AspNetCore.Diagnostics.dll";
286-
$refDiagnosticsDll = "$devRefPackDir/ref/net10.0/Microsoft.AspNetCore.Diagnostics.dll";
287-
288-
if ((Test-Path $runtimeDiagnosticsDll) -and (Test-Path (Split-Path $refDiagnosticsDll))) {
289-
Copy-Item -Path $runtimeDiagnosticsDll -Destination $refDiagnosticsDll -Force;
290-
Write-Verbose "Replaced reference Microsoft.AspNetCore.Diagnostics.dll with runtime version";
291-
Check-DiagnosticsDll -Path $refDiagnosticsDll -Description "5) Patched reference Microsoft.AspNetCore.Diagnostics.dll";
292+
$runtimeDiagnosticsDll = "$PSScriptRoot/.dotnet/shared/Microsoft.AspNetCore.App/10.0.0-dev/Microsoft.AspNetCore.Diagnostics.dll"
293+
$refDiagnosticsDll = "$devRefPackDir/ref/net10.0/Microsoft.AspNetCore.Diagnostics.dll"
294+
295+
if ((Test-Path $runtimeDiagnosticsDll) -and (Test-Path (Split-Path $refDiagnosticsDll)))
296+
{
297+
Copy-Item -Path $runtimeDiagnosticsDll -Destination $refDiagnosticsDll -Force
298+
Write-Verbose "Replaced reference Microsoft.AspNetCore.Diagnostics.dll with runtime version"
299+
Check-DiagnosticsDll -Path $refDiagnosticsDll -Description "5) Patched reference Microsoft.AspNetCore.Diagnostics.dll"
292300
}
293301
}
294302
}
295303
}
296-
} else {
297-
Write-Warning "Reference packs directory not found at $packsDir";
304+
}
305+
else
306+
{
307+
Write-Warning "Reference packs directory not found at $packsDir"
298308
}
299309

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

0 commit comments

Comments
 (0)