Skip to content
Simplified MSBuild-based build scripts
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Icon CoreBuild

Simplified MSBuild-based build scripts empowered by NuGet

CoreBuild leverages a feature called MSBuild Sdks, which were introduced very recently in MSBuild 15.0 (Visual Studio 15.6+ in particular) and allows simplified MSBuild project authoring. CoreBuild provides the necessary targets and properties to enable NuGet PackageReference support in your build scripts.


Just create your SDK-style MSBuild script project as follows:

<Project Sdk="CoreBuild/1.0.0-alpha">
	<!-- Your properties, targets and PackageReference items here -->

NOTE: Consider making it CoreBuild Standard compliant so that your contributors can easily know what steps are necessary to clone, configure, build, test and run your project.

Alternatively, you can download and boostrap the project in a single command by running the following on the folder you intend to create the new build.proj file, typically your repository root.

From a PowerShell command prompt:

curl -o build.proj; msbuild /nologo /v:m /t:configure; msbuild /nologo /t:help

From a regular command prompt using curl.exe:

curl -k -L -o build.proj && msbuild /nologo /v:m /t:configure && msbuild /nologo /t:help

This will download the sample project, run /t:Configure to restore packages, and run the /t:Help target so you can see how documentation can be authored and rendered nicely from your build project.


CoreBuild provides a basic starting point for writing build scripts using MSBuild taking advantage of the newest features of MSBuild 15+ and NuGet packages for consuming reusable MSBuild props, targets and tasks which is also CoreBuild Standard compliant.

CoreBuild also provides automatic targets and properties help via the the CoreBuild.Help package, which is automatically referenced by the SDK.


Writing MSBuild targets is getting considerably more convenient as MSBuild is evolving in v15.0 and beyond. Together with the built-in support for NuGet package restore from MSBuild, the combination is now much more powerfull and allows for more concise and readable build scripts.

Examples of the increased power allowed by this new combination:

  • Levaraging a NuGet package natively for doing versioning:

      		<PackageReference Include="GitInfo" Version="*" />
      	<Target Name="Build" DependsOnTargets="GitVersion">

    This brings the latest & greatest version of GitInfo for versioning the built artifacts, for example. Note the concise notation for item metadata (Version attribute above) as well as the floating dependency version.

  • Levaraging a NuGet package natively for detecting XBuild builds:

      		<PackageReference Include="MSBuilder.IsXBuild" Version="*" />
      	<Target Name="Build">
      		<Error Condition="'$(IsXBuild)' == 'true'" Text="This build script requires MSBuild." />

There are many more such reusable build blocks at MSBuilder.

  • Levaraging xunit NuGet package natively for running tests:

      		<PackageReference Include="xunit.runner.msbuild" Version="2.2.0" />
      		<TestAssembly Include="src\**\*Tests*.dll" />
      	<Target Name="Test">
      		<xunit Assemblies="@(TestAssembly)" />


In order to enable package restore from MSBuild, the CoreBuild SDK opts-in to the NuGet 4.0 features available in VS2017 for s"SDK Style" MSBuild projects, by specifying netstandard1.0 as its TargetFramework.

NuGet will automatically generate the restore artifacts in the .nuget folder alongside your build.proj, which is typically ignored by default in source control (i.e. via .gitignore):

		- build.proj
			- [nuget restore artifacts here, updated by /t:Restore]

The Sdk.props and Sdk.targets then import the generated targets from NuGet, allowing your main build.proj project to readily consume their artifacts. A typical build.proj therefore looks quite clean:

<Project Sdk="CoreBuild/[VERSION]" DefaultTargets="Build">

		<!-- Some PackageReferences for reusable MSBuild "scriptlets"... -->

	<Target Name="Build">

	<Target Name="Clean">

	<Target Name="Rebuild" DependsOnTargets="Clean;Build" />

You can’t perform that action at this time.