We have an on-premise Gitea installation with an action runner, and numerous working CI/CD workflows. The setup works with .Net Framework 4.8 and Dotnet 6.0 applications.
We recently built a Dotnet 8.0 app and when I try to build it using the action runner, I get an error saying the Dotnet 8 SDK is not installed, but it is indeed installed, so I'm not sure how to fix it, and would appreciate some help.
When I run dotnet --info
I get this:
Version: 8.0.407
Commit: cac65f27eb
Workload version: 8.0.400-manifests.20e9918b
MSBuild version: 17.11.26+2b19be476
Runtime Environment:
OS Name: Windows
OS Version: 10.0.17763
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\8.0.407\
And when I run dotnet --list-sdks
I get this:
6.0.300 [C:\Program Files\dotnet\sdk]
6.0.414 [C:\Program Files\dotnet\sdk]
7.0.102 [C:\Program Files\dotnet\sdk]
7.0.401 [C:\Program Files\dotnet\sdk]
8.0.406 [C:\Program Files\dotnet\sdk]
8.0.407 [C:\Program Files\dotnet\sdk]
So from what I can see, the Dotnet 8 SDK is installed correctly and should work, but the runner gives this error:
error NETSDK1045: The current .NET SDK does not support targeting .NET 8.0. Either target .NET 7.0 or lower, or use a version of the .NET SDK that supports .NET 8.0
Also, the directory the runner refers to is this: C:\Program Files\dotnet\sdk\7.0.401\
I have tried adding the Dotnet 8 SDK path to the PATH
environment variables but also to no avail.
The problem was with the MSBuild version used by the workflows. I believe its SDKs are independant from the OS's SDKs, so it was not targeting the newer SDKs even though they are installed on the OS.
MSBuild is shipped with Visual Studio Built Tools 2022, which in our case was the outdated culprit.
Updating it allowed me to publish dotnet 8 apps via workflows successfully.
Thanks Jason Pan for the comment suggesting I do a version check from within the workflow. That revealed the missing SDKs.