Skip to main content

Global Builds

Instead of adding and maintaining build projects in all your repositories, you can also build them by convention using a global build. Global builds are based on the concept of .NET global tools and additionally include all the necessary tools referenced through NuGet packages. That means that for building one of your repositories, you only need to install and execute your pre-packaged build.


As a first step, you need to extend the build project file with the necessary information for global tool packaging. Particularly, that includes the PackAsTool and ToolCommandName property:

<Project Sdk="Microsoft.NET.Sdk">



Note that PackageDownload can only be used in the .NET global tool project directly, since they do not work transitively. Alternatively, you can reference tools the old way via PackageReference and set the ExcludeAssets property:

<Project Sdk="Microsoft.NET.Sdk">

<PackageReference Include="NUnit.ConsoleRunner" Version="3.9.0" ExcludeAssets="all" />


Afterward, the project can be packaged and deployed as usual:

dotnet pack --version <version>
dotnet nuget push MyBuild.<version>.nupkg --source <source> --api-key <token>

Currently, single-file deployments are not supported. That means that the operating system must have the .NET SDK installed. Feel free to track the related GitHub issue for any updates.


Once the global build is packaged and deployed, you can install it either locally to a repository or globally on your development machine:

dotnet new tool-manifest
dotnet tool install MyBuild

When you want to guarantee reproducibility, local tools are the better fit since the version is pinned individually for every repository. Global tools, on the other hand, provide more convenience in that you're always building with the same version. This is especially helpful when your conventions, like folder structure and namings, are already well evolved.


After installation, you can invoke the build through the command that you've specified in ToolCommandName. As per the example from above:

dotnet my-build [args]