Frequently asked questions
Why do I see the warning “Solution foo.sln is missing an active build configuration for build.csproj”?
- Using NukeExt requires restoring a NuGet package, which Visual Studio and dotnet won’t do unless the build.csproj is configured for building. We could simply restore the build.csproj to avoid this, but it’s still a poor user experience in Visual Studio, so instead we require enabling it in the .sln.
Why are the Nuke scripts failing to run NuGet restore due to “error: NU1301: Unable to load the service index”?
- This error may occur if dotnet is unable to authenticate to a private NuGet feed. To resolve this:
- Install the Azure Artifacts Credential Provider.
- From PowerShell, run
iex "& { $(irm https://aka.ms/install-artifacts-credprovider.ps1) }"
- From PowerShell, run
- Run
dotnet restore --interactive, or if you’re using our global tools,dotnet tool update -g Microsoft.XboxStudios.NukeTool --version {insert version number here} --interactive- You may also need the
--verbosity minimalflag due to an upstream .NET bug. - Consider copying the build.sh and build.ps1 scripts from NukeExt which include these fixes.
- You may also need the
How do I setup Nuke in a different place than the root folder of my Git repository?
- By default the Nuke-generated Azure pipelines build assumes the
build.cmdscript is in the root folder. In case you want to move the Nuke build to a different folder or have multiple builds in one Git repo, you can use a feature specific to NukeExt to set theNukeBuildDirectory.
How do I integrate Git versioning into my build?
-
There are two easy ways to use Nerdbank.GitVersioning with Nuke:
- As suggested in the official docs, add a
PackageReferenceto your C# project. - In Nuke’s
parameters.json, set theAddGitVersioningproperty totrue
- As suggested in the official docs, add a
-
The tradeoff is generally that option 1 has a greater feature-set, such as the
ThisAssemblyvariable, while option 2 is simpler and more reliable. Option 1 works in Visual Studio, but its more complex NuGet package integration has caused issues in our Azure DevOps pipelines.
How do I publish multiple target frameworks, for example net472 and net8.0?
- NUKE supports this out-of-the-box
using
CombineWithto repeat a target multiple times. For example with cmd:or PowerShell:sqtech-build.exe --publish-frameworks net8.0 net472sqtech-build.exe --publish-frameworks @("net8.0", "net472")
How can I verify my build publishes specific files or patterns of files?
- When you’re signing your build artifacts, and expecting specific files to be included, NukeExt can check that with its
ValidatePublishOutputoption. For example inparameters.json, this will validate theartifacts/bin/NukeToolandNukeTool.DocFXfolders each contain DLL files with any name and also one specific EXE file. Note that only DLL and EXE files are checked, and for greater security you should also enumerate the expected DLL files or file patterns."ValidatePublishOutput": ["NukeTool: *.dll, NukeTool.exe","NukeTool.DocFX: *.dll NukeTool.DocFX.exe"]