@@ -43,26 +43,82 @@ jobs:
4343 - name : Setup MSBuild
44444545
46- - name : Build SQL Server Database project
46+ - name : Build SQL Server Database Project
4747 run : |
48- # List all .sqlproj files except for .sqlproj
48+ # Enable strict error handling
49+ $ErrorActionPreference = 'Stop'
50+
51+ # Initialize an error collection
52+ $errors = @()
53+
54+ # List all .sqlproj files
4955 $sqlproj_files = Get-ChildItem -Path . -Filter *.sqlproj -Recurse
50-
51- # Build each .csproj file
52- foreach ($sqlproj_file in $sqlproj_files) {
53- Write-Host "Building $($sqlproj_file.FullName)"
54- msbuild "$($sqlproj_file.FullName)" /p:Configuration=Release
55- }
56- - name : Build solution excluding SQL project
56+
57+ if ($sqlproj_files.Count -eq 0) {
58+ $errors += "No .sqlproj files found."
59+ } else {
60+ foreach ($sqlproj_file in $sqlproj_files) {
61+ Write-Host "Building $($sqlproj_file.FullName)"
62+ try {
63+ msbuild "$($sqlproj_file.FullName)" /p:Configuration=Release
64+ if (!$?) {
65+ $errors = "Failed to build $($sqlproj_file.FullName)"
66+ }
67+ } catch {
68+ $errors += $_.Exception.Message
69+ }
70+ }
71+ }
72+
73+ # Display any accumulated errors
74+ if ($errors.Count -gt 0) {
75+ Write-Error "SQL Project Build Errors:"
76+ $errors | ForEach-Object { Write-Error $_ }
77+ }
78+
79+ # Exit with failure if there are errors
80+ if ($errors.Count -gt 0) {
81+ exit 1
82+ }
83+
84+ - name : Build Solution Excluding SQL Project
5785 run : |
58- # List all .csproj files except for .sqlproj
86+ # Enable strict error handling
87+ $ErrorActionPreference = 'Stop'
88+
89+ # Initialize an error collection
90+ $errors = @()
91+
92+ # List all .csproj files except .sqlproj
5993 $csproj_files = Get-ChildItem -Path . -Filter *.csproj -Recurse | Where-Object { $_.FullName -notmatch '\\.sqlproj$' }
60- # Build each .csproj file
61- foreach ($csproj_file in $csproj_files) {
62- Write-Host "Building $($csproj_file.FullName)"
63- dotnet build "$($csproj_file.FullName)"
64- }
94+
95+ if ($csproj_files.Count -eq 0) {
96+ $errors += "No .csproj files found."
97+ } else {
98+ foreach ($csproj_file in $csproj_files) {
99+ Write-Host "Building $($csproj_file.FullName)"
100+ try {
101+ dotnet build "$($csproj_file.FullName)" --configuration Release
102+ if (!$?) {
103+ $errors = "Failed to build $($csproj_file.FullName)"
104+ }
105+ } catch {
106+ $errors += $_.Exception.Message
107+ }
108+ }
109+ }
65110
111+ # Display any accumulated errors
112+ if ($errors.Count -gt 0) {
113+ Write-Error "Solution Build Errors:"
114+ $errors | ForEach-Object { Write-Error $_ }
115+ }
116+
117+ # Exit with failure if there are errors
118+ if ($errors.Count -gt 0) {
119+ exit 1
120+ }
121+
66122 # - name: Test
67123 # run: dotnet test ${{ env.BuildParameters.TestProjects }}
68124
0 commit comments