These instructions will lead you through the requirements to build dotnet/runtime on Windows.
You must install several components to build the dotnet/runtime repository. These instructions were tested on Windows 10 Pro, version 1903.
The runtime repository requires long paths to be enabled. Follow the instructions provided here to enable that feature.
If using Git for Windows you might need to also configure long paths there. Using an admin terminal simply type:
git config --system core.longpaths true
- Install Visual Studio 2019. The Community edition is available free of charge.
Visual Studio 2019 installation process:
- It's recommended to use 'Workloads' installation approach. The following are the minimum requirements:
- .NET Desktop Development with all default components.
- Desktop Development with C++ with all default components.
- To build for Arm32 or Arm64, make sure that you have the right architecture-specific compilers installed. In the "Individual components" window, in the "Compilers, build tools, and runtimes" section:
- For Arm32, check the box for "MSVC v142 - VS 2019 C++ ARM build tools (v14.23 or newer)".
- For Arm64, check the box for "MSVC v142 - VS 2019 C++ ARM64 build tools (v14.23 or newer)".
- To build the tests, you will need some additional components:
- Windows 10 SDK component version 10.0.18362 or newer. This component is installed by default as a part of 'Desktop Development with C++' workload.
- C++/CLI support for v142 build tools (v14.23 or newer)
A .vsconfig
file is included in the root of the dotnet/runtime repository that includes all components needed to build the dotnet/runtime repository. You can import .vsconfig
in your Visual Studio installer to install all necessary components.
The dotnet/runtime repository requires at least Visual Studio 2019 16.6.
- Install CMake for Windows.
- Add its location (e.g. C:\Program Files (x86)\CMake\bin) to the PATH environment variable. The installation script has a check box to do this, but you can do it yourself after the fact following the instructions at Adding to the Default PATH variable.
The dotnet/runtime repository recommends using CMake 3.16.4 or newer, but it may work with CMake 3.15.5.
- Install Ninja in one of the two following ways
- Download the executable and add its location to the Default PATH variable.
- Install via a package manager, which should automatically add it to the PATH environment variable.
- Install Python for Windows.
- Add its location (e.g. C:\Python*) to the PATH environment variable. The installation script has a check box to do this, but you can do it yourself after the fact following the instructions at Adding to the Default PATH variable.
The dotnet/runtime repository requires at least Python 3.7.4.
- Install Git for Windows.
- Add its location (e.g. C:\Program Files\Git\cmd) to the PATH environment variable. The installation script has a check box to do this, but you can do it yourself after the fact following the instructions at Adding to the Default PATH variable.
The dotnet/runtime repository requires at least Git 2.22.0.
- Ensure that
powershell.exe
is accessible via the PATH environment variable. Typically this is%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\
and its automatically set upon Windows installation. - Powershell version must be 3.0 or higher. Use
$PSVersionTable.PSVersion
to determine the engine version.
While not strictly needed to build or test this repository, having the .NET SDK installed lets you browse solution files in this repository with Visual Studio and use the dotnet.exe command to run .NET applications in the 'normal' way. We use this in the Using Your Build instructions. The minimum required version of the SDK is specified in the global.json file. You can find the installers and binaries for nightly builds of .NET SDK here.
Alternatively, to avoid modifying your machine state, you can use the repository's locally acquired SDK by passing in the solution to load via the -vs
switch:
build.cmd -vs System.Text.RegularExpressions
This will set the DOTNET_ROOT
and PATH
environment variables to point to the locally acquired SDK under runtime\.dotnet\
and will launch the Visual Studio instance which is registered for the sln
extension.
The commands above need to be on your command lookup path. Some installers will automatically add them to the path as part of the installation, but if not here is how you can do it.
You can, of course, add a directory to the PATH environment variable with the syntax set PATH=%PATH%;DIRECTORY_TO_ADD_TO_PATH
.
However, the change above will only last until the command windows close. You can make your change to the PATH variable persistent by going to Control Panel -> System And Security -> System -> Advanced system settings -> Environment Variables, and select the 'Path' variable in the 'System variables' (if you want to change it for all users) or 'User variables' (if you only want to change it for the current user). Simply edit the PATH variable's value and add the directory (with a semicolon separator).