|
| 1 | +<# |
| 2 | +.SYNOPSIS |
| 3 | + Builds a list of project files in the dogfood environment. |
| 4 | +.DESCRIPTION |
| 5 | + This script enters the dogfood environment and builds the specified project files. |
| 6 | +#> |
| 7 | +[CmdletBinding(PositionalBinding=$false)] |
| 8 | +Param( |
| 9 | + [string] $configuration = "Release" |
| 10 | +) |
| 11 | + |
| 12 | +function Build-Projects { |
| 13 | + $ErrorActionPreference = 'Stop' |
| 14 | + $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" |
| 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 | + ) |
| 43 | + |
| 44 | + Write-Host "Building projects in the dogfood environment..." -ForegroundColor Cyan |
| 45 | + |
| 46 | + # Call dogfood.ps1 directly instead of through dogfood.cmd to avoid the -NoExit parameter |
| 47 | + $dogfoodPs1 = Join-Path $RepoRoot "eng\dogfood.ps1" |
| 48 | + |
| 49 | + foreach ($projectFile in $ProjectFiles) { |
| 50 | + $fullProjectPath = Join-Path $RepoRoot $projectFile |
| 51 | + |
| 52 | + # Check if the project file exists |
| 53 | + if (-not (Test-Path $fullProjectPath)) { |
| 54 | + Write-Error "Project file not found at: $fullProjectPath" |
| 55 | + return 1 |
| 56 | + } |
| 57 | + |
| 58 | + Write-Host "Executing: dotnet build $fullProjectPath via dogfood environment" -ForegroundColor Gray |
| 59 | + # Pass the command directly to the dogfood.ps1 script |
| 60 | + & $dogfoodPs1 -configuration $configuration -command "dotnet", "build", $fullProjectPath |
| 61 | + $exitCode = $LASTEXITCODE |
| 62 | + if ($exitCode -ne 0) { |
| 63 | + Write-Error "Build failed for project: $fullProjectPath with exit code: $exitCode" |
| 64 | + return $exitCode |
| 65 | + } else { |
| 66 | + Write-Host "Build completed successfully for project: $fullProjectPath" -ForegroundColor Green |
| 67 | + } |
| 68 | + } |
| 69 | + |
| 70 | + return 0 |
| 71 | +} |
| 72 | + |
| 73 | +# Execute the function using Invoke-Command |
| 74 | +$exitCode = Invoke-Command -ScriptBlock ${function:Build-Projects} |
| 75 | +exit $exitCode |
0 commit comments