Skip to content

Commit 86aadef

Browse files
Update script
1 parent 6d5086b commit 86aadef

File tree

1 file changed

+40
-30
lines changed

1 file changed

+40
-30
lines changed

build/BuildTestTemplates.ps1

+40-30
Original file line numberDiff line numberDiff line change
@@ -12,47 +12,50 @@ Param(
1212
function Build-Projects {
1313
$ErrorActionPreference = 'Stop'
1414
$RepoRoot = Resolve-Path (Join-Path $PSScriptRoot '..')
15-
16-
# Define constants for common path segments
17-
$TemplateFeedPath = "template_feed\Microsoft.DotNet.Common.ProjectTemplates.10.0\content"
18-
$MSTestPath = "$TemplateFeedPath\MSTest"
19-
$NUnitPath = "$TemplateFeedPath\NUnit"
20-
$XUnitPath = "$TemplateFeedPath\XUnit"
21-
$PlaywrightMSTestPath = "$TemplateFeedPath\Playwright-MSTest"
22-
$PlaywrightNUnitPath = "$TemplateFeedPath\Playwright-NUnit"
2315

24-
# Define the project files using the constants
25-
$ProjectFiles = @(
26-
# MSTest Projects
27-
"$MSTestPath-CSharp\Company.TestProject1.csproj",
28-
"$MSTestPath-FSharp\Company.TestProject1.fsproj",
29-
"$MSTestPath-VisualBasic\Company.TestProject1.vbproj",
30-
"$PlaywrightMSTestPath-CSharp\Company.TestProject1.csproj",
31-
32-
# NUnit Projects
33-
"$NUnitPath-CSharp\Company.TestProject1.csproj",
34-
"$NUnitPath-FSharp\Company.TestProject1.fsproj",
35-
"$NUnitPath-VisualBasic\Company.TestProject1.vbproj",
36-
"$PlaywrightNUnitPath-CSharp\Company.TestProject1.csproj",
37-
38-
# XUnit Projects
39-
"$XUnitPath-CSharp\Company.TestProject1.csproj",
40-
"$XUnitPath-FSharp\Company.TestProject1.fsproj",
41-
"$XUnitPath-VisualBasic\Company.TestProject1.vbproj"
42-
)
16+
# Define constants for common path segments
17+
$TemplateFeedPath = "template_feed\Microsoft.DotNet.Common.ProjectTemplates.10.0\content"
18+
$MSTestPath = "$TemplateFeedPath\MSTest"
19+
$NUnitPath = "$TemplateFeedPath\NUnit"
20+
$XUnitPath = "$TemplateFeedPath\XUnit"
21+
$PlaywrightMSTestPath = "$TemplateFeedPath\Playwright-MSTest"
22+
$PlaywrightNUnitPath = "$TemplateFeedPath\Playwright-NUnit"
23+
24+
# Define the project files using the constants
25+
$ProjectFiles = @(
26+
# MSTest Projects
27+
"$MSTestPath-CSharp\Company.TestProject1.csproj",
28+
"$MSTestPath-FSharp\Company.TestProject1.fsproj",
29+
"$MSTestPath-VisualBasic\Company.TestProject1.vbproj",
30+
"$PlaywrightMSTestPath-CSharp\Company.TestProject1.csproj",
31+
32+
# NUnit Projects
33+
"$NUnitPath-CSharp\Company.TestProject1.csproj",
34+
"$NUnitPath-FSharp\Company.TestProject1.fsproj",
35+
"$NUnitPath-VisualBasic\Company.TestProject1.vbproj",
36+
"$PlaywrightNUnitPath-CSharp\Company.TestProject1.csproj",
37+
38+
# XUnit Projects
39+
"$XUnitPath-CSharp\Company.TestProject1.csproj",
40+
"$XUnitPath-FSharp\Company.TestProject1.fsproj",
41+
"$XUnitPath-VisualBasic\Company.TestProject1.vbproj"
42+
)
4343

4444
Write-Host "Building projects in the dogfood environment..." -ForegroundColor Cyan
4545

4646
# Call dogfood.ps1 directly instead of through dogfood.cmd to avoid the -NoExit parameter
4747
$dogfoodPs1 = Join-Path $RepoRoot "eng\dogfood.ps1"
4848

49+
$failedProjects = @()
50+
4951
foreach ($projectFile in $ProjectFiles) {
5052
$fullProjectPath = Join-Path $RepoRoot $projectFile
5153

5254
# Check if the project file exists
5355
if (-not (Test-Path $fullProjectPath)) {
5456
Write-Error "Project file not found at: $fullProjectPath"
55-
return 1
57+
$failedProjects += $fullProjectPath
58+
continue
5659
}
5760

5861
Write-Host "Executing: dotnet build $fullProjectPath via dogfood environment" -ForegroundColor Gray
@@ -61,13 +64,20 @@ function Build-Projects {
6164
$exitCode = $LASTEXITCODE
6265
if ($exitCode -ne 0) {
6366
Write-Error "Build failed for project: $fullProjectPath with exit code: $exitCode"
64-
return $exitCode
67+
$failedProjects += $fullProjectPath
6568
} else {
6669
Write-Host "Build completed successfully for project: $fullProjectPath" -ForegroundColor Green
6770
}
6871
}
6972

70-
return 0
73+
if ($failedProjects.Count -gt 0) {
74+
Write-Error "The following projects failed to build:"
75+
$failedProjects | ForEach-Object { Write-Error $_ }
76+
return 1
77+
} else {
78+
Write-Host "All projects built successfully!" -ForegroundColor Green
79+
return 0
80+
}
7181
}
7282

7383
# Execute the function using Invoke-Command

0 commit comments

Comments
 (0)