Skip to content

Commit fa3136f

Browse files
The test projects won't restore under dotnet 10
1 parent 9197f23 commit fa3136f

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

.github/workflows/dotnet-tests.yml

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,37 @@ jobs:
3232
- name: Build
3333
run: dotnet build DotNetBuildable.slnf /p:Configuration=Release
3434

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
3636
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+
}
3866
3967
- name: Log MSBuild version
4068
run: msbuild -version

0 commit comments

Comments
 (0)