How to use Nuke.Build to install a .NET Sdk in GitHub Actions?
- Basically, I try to use Nuke.Build to setup GitHub Actions to build and test a Blazor project. The project uses the .NET 8 preview SDK. So, I will need to install the new SDK somehow.
- But I don't know how to do it. I cannot find the instruction in the Nuke.Build documentation
Thank you for your help.
When you setup Nuke using
nuke :setupit generates some bootstraping scripts:build.cmd,build.ps1andbuild.sh(see Nuke - Build setup - Project structure).By default, these scripts determine the .NET version to use from a
global.jsonfile in the same directory and default to the STS channel if the file does not exists or no version is specified. So in your case you will want to have aglobal.jsonfile that look like the following:Then you will need to configure your targets to generate Github workflow files (see Nuke - GitHub Actions). After running your build with the
nukecommand you should see a line like this in the generated workflow file:This indicates that the bootstrapping script will be executed and set up the environment before running your target, including installing the desired .NET SDK version.