@@ -190,83 +190,30 @@ jobs:
190190 echo "order=$orderString" >> $env:GITHUB_OUTPUT
191191 shell : pwsh
192192
193- - name : Build repositories in dependency order
193+ - name : Build repositories in dependency order (clean detection)
194+ shell : pwsh
194195 run : |
195196 $buildOrder = "${{ steps.build-order.outputs.order }}" -split ","
196197 foreach ($repo in $buildOrder) {
197198 $repo = $repo.Trim()
198- if ($repo -ne "") {
199- Write-Host "Building $repo..."
200- Push-Location ".repos/$repo"
201-
202- # Find solution files
203- $solutionFiles = Get-ChildItem -Recurse -Filter "*.sln" | Where-Object { $_.Directory.Name -notmatch "(Test|Tests|Example|Examples)" }
204-
205- if ($solutionFiles.Count -gt 0) {
206- $solutionFile = $solutionFiles[0].FullName
207- Write-Host "Building solution: $solutionFile"
208-
209- # Try dotnet first
210- Write-Host "Restoring packages with dotnet..."
211- dotnet restore "$solutionFile"
212- if ($LASTEXITCODE -eq 0) {
213- Write-Host "Building with dotnet..."
214- dotnet build "$solutionFile" --configuration Release --verbosity minimal --no-restore
215- if ($LASTEXITCODE -ne 0) {
216- Write-Host "Dotnet build failed, trying MSBuild fallback..."
217- nuget restore "$solutionFile"
218- msbuild "$solutionFile" /p:Configuration=Release /p:Platform="Any CPU" /verbosity:minimal
219- if ($LASTEXITCODE -ne 0) {
220- Write-Host "MSBuild also failed for $repo, continuing with next repository..."
221- }
222- }
223- } else {
224- Write-Host "Dotnet restore failed, trying NuGet + MSBuild fallback..."
225- nuget restore "$solutionFile"
226- msbuild "$solutionFile" /p:Configuration=Release /p:Platform="Any CPU" /verbosity:minimal
227- if ($LASTEXITCODE -ne 0) {
228- Write-Host "MSBuild failed for $repo, continuing with next repository..."
229- }
230- }
231- } else {
232- # Try to find project files if no solution
233- $projectFiles = Get-ChildItem -Recurse -Filter "*.csproj" | Where-Object { $_.Directory.Name -notmatch "(Test|Tests|Example|Examples)" }
234- if ($projectFiles.Count -gt 0) {
235- foreach ($projectFile in $projectFiles) {
236- Write-Host "Building project: $($projectFile.FullName)"
237-
238- # Try dotnet first
239- dotnet restore "$($projectFile.FullName)"
240- if ($LASTEXITCODE -eq 0) {
241- dotnet build "$($projectFile.FullName)" --configuration Release --verbosity minimal --no-restore
242- if ($LASTEXITCODE -ne 0) {
243- Write-Host "Dotnet build failed for project $($projectFile.Name), trying MSBuild..."
244- nuget restore "$($projectFile.FullName)"
245- msbuild "$($projectFile.FullName)" /p:Configuration=Release /p:Platform="Any CPU" /verbosity:minimal
246- if ($LASTEXITCODE -ne 0) {
247- Write-Host "MSBuild also failed for project $($projectFile.Name), continuing..."
248- break
249- }
250- }
251- } else {
252- Write-Host "Dotnet restore failed for project $($projectFile.Name), trying NuGet + MSBuild..."
253- nuget restore "$($projectFile.FullName)"
254- msbuild "$($projectFile.FullName)" /p:Configuration=Release /p:Platform="Any CPU" /verbosity:minimal
255- if ($LASTEXITCODE -ne 0) {
256- Write-Host "MSBuild failed for project $($projectFile.Name), continuing..."
257- break
258- }
259- }
260- }
261- } else {
262- Write-Host "No solution or project files found in $repo"
263- }
199+ if (-not $repo) { continue }
200+ Push-Location ".repos/$repo"
201+ Write-Host "Building $repo..."
202+
203+ # Prefer a solution if present; otherwise build each csproj
204+ $solutions = Get-ChildItem -Recurse -Filter *.sln | Where-Object { $_.Directory.Name -notmatch '(Test|Tests|Example|Examples)' }
205+ if ($solutions) {
206+ # Build the first solution (or loop them if you have multiple)
207+ $sln = $solutions[0].FullName
208+ ../../.github/workflows/build.ps1 -SolutionOrProjectPath $sln
209+ } else {
210+ $projects = Get-ChildItem -Recurse -Filter *.csproj | Where-Object { $_.Directory.Name -notmatch '(Test|Tests|Example|Examples)' }
211+ foreach ($proj in $projects) {
212+ ../../.github/workflows/build.ps1 -SolutionOrProjectPath $proj.FullName
264213 }
265-
266- Pop-Location
267214 }
215+ Pop-Location
268216 }
269- shell : powershell
270217
271218 - name : Build Generation solution
272219 run : |
0 commit comments