|
32 | 32 | - name: Build |
33 | 33 | run: dotnet build DotNetBuildable.slnf /p:Configuration=Release |
34 | 34 |
|
35 | | - - name: Create global.json to enforce .NET 8 for MSBuild |
| 35 | + - name: Create global.json to enforce .NET 8 for MSBuild and update Tests/TestData projects |
36 | 36 | if: inputs.dotnet-version == '8.0.x' |
37 | | - run: echo '{"sdk":{"version":"8.0.0","rollForward":"latestFeature"}}' > global.json |
| 37 | + shell: pwsh |
| 38 | + run: | |
| 39 | + # ensure .NET 8 SDK is used for MSBuild operations |
| 40 | + '{"sdk":{"version":"8.0.0","rollForward":"latestFeature"}}' | Out-File -FilePath global.json -Encoding utf8 |
| 41 | + Write-Host "Updating <TargetFramework>net10.0...</TargetFramework> entries to net8.0 under Tests/TestData" |
| 42 | +
|
| 43 | + # Replace net10.0 and net10.0-windows with net8.0 / net8.0-windows respectively |
| 44 | + $projFiles = Get-ChildItem -Path Tests/TestData -Recurse -Include *.csproj,*.vbproj,*.fsproj -ErrorAction SilentlyContinue |
| 45 | + foreach ($f in $projFiles) { |
| 46 | + $path = $f.FullName |
| 47 | + $content = Get-Content -Path $path -Raw -ErrorAction Stop |
| 48 | + $updated = $content -replace '<TargetFramework>net10.0(-windows)?</TargetFramework>', '<TargetFramework>net8.0$1</TargetFramework>' |
| 49 | + if ($updated -ne $content) { |
| 50 | + Write-Host "Updating: $path" |
| 51 | + $updated | Set-Content -Path $path -Encoding utf8 |
| 52 | + } |
| 53 | + } |
| 54 | +
|
| 55 | + # If any files were changed, commit them so the working tree is clean for subsequent test steps. |
| 56 | + $status = git status --porcelain |
| 57 | + if ($status) { |
| 58 | + git config user.name "github-actions[bot]" |
| 59 | + git config user.email "${{ github.actor }}@users.noreply.github.com" |
| 60 | + git add -A |
| 61 | + git commit -m "CI: Update Tests/TestData TargetFramework -> net8.0 for .NET 8 run" || Write-Host "git commit returned non-zero (possibly no staged changes)" |
| 62 | + Write-Host "Committed changes to local repo (not pushed)." |
| 63 | + } else { |
| 64 | + Write-Host "No project files needed updating." |
| 65 | + } |
38 | 66 |
|
39 | 67 | - name: Log MSBuild version |
40 | 68 | run: msbuild -version |
|
0 commit comments