@@ -43,25 +43,77 @@ jobs:
4343
4444 - name : Build SQL Server Database project
4545 run : |
46- # List all .sqlproj files except for .sqlproj
46+ # Enable strict error handling
47+ $ErrorActionPreference = 'Stop'
48+
49+ # Initialize an error collection
50+ $errors = @()
51+
52+ # List all .sqlproj files
4753 $sqlproj_files = Get-ChildItem -Path . -Filter *.sqlproj -Recurse
48-
49- # Build each .csproj file
50- foreach ($sqlproj_file in $sqlproj_files) {
51- Write-Host "Building $($sqlproj_file.FullName)"
52- msbuild "$($sqlproj_file.FullName)" /p:Configuration=Release
53- }
54-
55- - name : Build solution excluding SQL project
54+
55+ if ($sqlproj_files.Count -eq 0) {
56+ $errors += "No .sqlproj files found."
57+ } else {
58+ foreach ($sqlproj_file in $sqlproj_files) {
59+ Write-Host "Building $($sqlproj_file.FullName)"
60+ try {
61+ $output = &msbuild "$($sqlproj_file.FullName)" /p:Configuration=Release /nologo 2>&1
62+ if (!$?) {
63+ $errors += "Failed to build $($csproj_file.FullName) : $output"
64+ }
65+ } catch {
66+ # Capture detailed error information
67+ $errorMessage = "Error building $($sqlproj_file.FullName) : $($_.Exception.Message)"
68+ Write-Host $errorMessage
69+ $errors += $errorMessage
70+ }
71+ }
72+ }
73+
74+ # Display all accumulated errors
75+ if ($errors.Count -gt 0) {
76+ Write-Host "SQL Project Build Errors:"
77+ $errors | ForEach-Object { Write-Host $_ }
78+ exit 1
79+ }
80+
81+ - name : Build Solution Excluding SQL Project
5682 run : |
57- # List all .csproj files except for .sqlproj
83+ # Enable strict error handling
84+ $ErrorActionPreference = 'Stop'
85+
86+ # Initialize an error collection
87+ $errors = @()
88+
89+ # List all .csproj files except .sqlproj
5890 $csproj_files = Get-ChildItem -Path . -Filter *.csproj -Recurse | Where-Object { $_.FullName -notmatch '\\.sqlproj$' }
59-
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- }
91+
92+ if ($csproj_files.Count -eq 0) {
93+ $errors += "No .csproj files found."
94+ } else {
95+ foreach ($csproj_file in $csproj_files) {
96+ Write-Host "Building $($csproj_file.FullName)"
97+ try {
98+ $output = &dotnet build "$($csproj_file.FullName)" --configuration Release 2>&1
99+ if (!$?) {
100+ $errors += "Failed to build $($csproj_file.FullName) : $output"
101+ }
102+ } catch {
103+ # Capture detailed error information
104+ $errorMessage = "Error building $($csproj_file.FullName) : $($_.Exception.Message)"
105+ Write-Host $errorMessage
106+ $errors += $errorMessage
107+ }
108+ }
109+ }
110+
111+ # Display all accumulated errors
112+ if ($errors.Count -gt 0) {
113+ Write-Host "Solution Build Errors:"
114+ $errors | ForEach-Object { Write-Host $_ }
115+ exit 1
116+ }
65117
66118 # - name: Test
67119 # run: dotnet test ${{ env.BuildParameters.TestProjects }}
0 commit comments