Skip to content

Instantly share code, notes, and snippets.

Last active January 10, 2024 10:06
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save bash/75af139564ce559a4ce521b8108a499f to your computer and use it in GitHub Desktop.
A Hitchhiker's Guide to MSBuild, the .NET SDK, and Everything

A Hitchhiker's Guide to MSBuild, the .NET SDK, and Everything


I am no longer actively updating this document.


Additional MSBuild SDKs





  • Private: When set to "false" the assembly is not copied to the output directory.



This item allows one to customize the path in the output directory.

<ContentWithTargetPath Update="Gui\Templates\**\*.*">


	<InternalsVisibleTo Include="Example.Tests" />

Tips and Tricks when using .msbuildproj

Error: The FrameworkReference 'NETStandard.Library' was not recognized

<PropertyGroup Condition="$(MSBuildProjectExtension) == '.msbuildproj'">
    <!-- This suppresses a build error that only happens in Visual Studio. See -->

Customizing dotnet run

dotnet run can be customized throught MSBuild by setting one or more of the following properties:

Property Name Description Default for .NET Core*
RunCommand Overrides the commmand of the executed process. dotnet.exe
RunArguments Overrides all arguments passed to the exeuted process. -
RunWorkingDirectory Configures the working directory. Wins over StartWorkingDirectory project directory
StartArguments Appends to the arguments passed to the executed process. "<AssemblyName>.dll"
StartWorkingDirectory Configures the working directory. -

* Varies depending on your settings. See Microsoft.NET.Sdk.targets

Use Case 1: Run something completely custom

Override both RunCommand and RunArguments:

	<RunArguments>&quot;Hello World&quot;</RunArguments>

Use Case 2: Add CLI arguments for your executable

Override StartArguments:

	<StartArguments>--logging-level Verbose</RunCommand>

Creating a Source Code Package

Example csproj:

<!-- ... -->
    <Content Include="Metadata\**\*.cs">
<!-- ... -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment