Building in Visual Studio / Code

Before opening our .sln files in Visual Studio or VS Code, executing the following on command-line:

build.cmd /t:Restore

This will download required tools.

Auto-update

There are typically new builds of tools and packages available every day. To automatically update to the latest versions, run the following:

build.cmd -Update /t:Restore

PATH

For VS Code and Visual Studio to work correctly, you must place the following location in your PATH.

Windows: %USERPROFILE%\.dotnet\x64
Linux/macOS: $HOME/.dotnet

This must come before any other installation of dotnet. In Windows, we recommend removing C:\Program Files\dotnet from PATH in system variables and adding %USERPROFILE%\.dotnet\x64 to PATH in user variables.

Building on command-line

Most repositories in https://github.com/aspnet/ have a build.cmd or build.sh script in the repository root. Executing this script will begin building the default lifecycle. The steps of the default lifecycle, in order, are:

  1. Prepare
  2. Restore
  3. Compile
  4. Package
  5. Test
  6. Verify
  7. Build**

** This is the default build target.

To run only a portion of the lifecycle, add arguments in the form /target:$name or /t:$name for short. For example:

./build.sh /t:Compile

Build properties

Additional properties can be added as an argument in the form /property:$name=$value, or /p:$name=$value for short. For example:

build.cmd /p:Configuration=Release

Common properties include:

Property Description
BuildNumber (string). A specific build number, typically from a CI counter
Configuration Debug or Release. Default = Debug.
IncrementalVersion true or false. Default = false. When true, BuildNumber will be automatically set based on the current timestamp.