Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 66 additions & 12 deletions docs/building/windows-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,62 @@ You can build ML.NET either via the command line or by using Visual Studio.

## Required Software

1. **[Visual Studio 2019 Version 16.4+](https://www.visualstudio.com/downloads/) (Community, Professional, Enterprise)** The Community version is completely free. The below build instructions were verified for VS 16.4.
2. **[CMake](https://cmake.org/)** must be installed from [the CMake download page](https://cmake.org/download/#latest) and added to your path. If you want to use Visual Studio 2022, you need to be using at least CMake 3.21.
1. **[Visual Studio 2019 Version 16.4+](https://www.visualstudio.com/downloads/), [Visual Studio 2022](https://www.visualstudio.com/downloads/), or [Visual Studio 2026](https://www.visualstudio.com/downloads/) (Community, Professional, Enterprise)** The Community version is completely free. The below build instructions have been verified for VS 2019 (16.4+), VS 2022, and VS 2026.
2. **[CMake](https://cmake.org/)** must be installed from [the CMake download page](https://cmake.org/download/#latest) and added to your path.
* For Visual Studio 2019: CMake 3.14 or higher is required.
* For Visual Studio 2022: CMake 3.21 or higher is required.
* For Visual Studio 2026: CMake 4.2 or higher is required.
* CMake 4.0 and later versions are supported.

### Visual Studio 2019 Installation
We have successfully verified the below build instructions for Visual Studio version 16.4 and higher.
### Visual Studio Installation

#### Visual Studio 2019 - 'Workloads' based install
The installation requirements are similar across Visual Studio 2019, 2022, and 2026. The main differences are the version numbers of the MSVC toolsets and specific SDK requirements. Below are examples for different Visual Studio versions.

#### Visual Studio 2022 (Example)
Visual Studio 2022 requires the following components for native code compilation. Similar components are required for Visual Studio 2019 and 2026, with corresponding MSVC toolset versions (v142 for VS 2019, v143 for VS 2022, v145 for VS 2026).

##### Visual Studio 2022 - 'Workloads' based install

The following are the minimum requirements:
* .NET desktop development
* All Required Components
* .NET Framework 4-4.6 Development Tools
* Desktop development with C++
* All Required Components
* MSVC v143 - VS 2022 C++ x64/x86 build tools (Latest)
* MSVC v143 - VS 2022 C++ x64/x86 Spectre-mitigated libs (Latest)
* Windows 11 SDK (or Windows 10 SDK)
* .NET Core cross-platform development
* All Required Components

##### Visual Studio 2022 - 'Individual components' based install

The following are the minimum requirements:
* C# and Visual Basic Roslyn Compilers
* .NET 6.0 SDK or later
* Static Analysis Tools
* .NET Portable Library Targeting Pack
* Visual Studio C++ Core Features
* MSVC v143 - VS 2022 C++ x64/x86 build tools (Latest)
* MSVC v143 - VS 2022 C++ x64/x86 Spectre-mitigated libs (Latest)
* MSBuild
* .NET Framework 4.6 Targeting Pack
* Windows Universal CRT SDK

**Note**: The Spectre-mitigated libraries are required for building native components with Visual Studio. These can be found in the "Individual components" section of the Visual Studio Installer under "Compilers, build tools, and runtimes". Select the version corresponding to your Visual Studio installation (v142 for VS 2019, v143 for VS 2022, v145 for VS 2026).

##### Visual Studio 2022 - Cross compilation for ARM

If you want to cross compile for ARM you will also need from the 'Individual components' section:
* MSVC v143 - VS 2022 C++ ARM build tools (Latest)
* MSVC v143 - VS 2022 C++ ARM64 build tools (Latest)
* MSVC v143 - VS 2022 C++ ARM Spectre-mitigated libs (Latest)
* MSVC v143 - VS 2022 C++ ARM64 Spectre-mitigated libs (Latest)

#### Visual Studio 2019 (Example)
Visual Studio 2019 (version 16.4+) requires similar components but uses MSVC v142 toolset instead of v143.

##### Visual Studio 2019 - 'Workloads' based install

The following are the minimum requirements:
* .NET desktop development
Expand All @@ -24,7 +73,7 @@ The following are the minimum requirements:
* .NET Core cross-platform development
* All Required Components

#### Visual Studio 2019 - 'Individual components' based install
##### Visual Studio 2019 - 'Individual components' based install

The following are the minimum requirements:
* C# and Visual Basic Roslyn Compilers
Expand All @@ -37,17 +86,17 @@ The following are the minimum requirements:
* .NET Framework 4.6 Targeting Pack
* Windows Universal CRT SDK

#### Visual Studio 2019 - Cross compilation for ARM
##### Visual Studio 2019 - Cross compilation for ARM

If you want to cross compile for arm you will also need from the 'Individual components' section:
If you want to cross compile for ARM you will also need from the 'Individual components' section:
* MSVC v142 - VS 2019 C++ ARM build tools
* MSVC v142 - VS 2019 C++ ARM64 build tools

## Building Instructions

In order to fetch dependencies which come through Git submodules the following command needs to be run before building: `git submodule update --init`.

### Building From Visual Studio 2019
### Building From Visual Studio

First, set up the required tools, from a (non-admin) Command Prompt window:

Expand All @@ -57,7 +106,7 @@ After successfully running the command, the project can be built directly from t

### Building From the Command Line

You can use the Developer Command Prompt, Powershell or work in any regular cmd. The Developer Command Prompt will have a name like "Developer Command Prompt for VS 2019" or similar in your start menu.
You can use the Developer Command Prompt, Powershell or work in any regular cmd. The Developer Command Prompt will have a name like "Developer Command Prompt for VS 2019" or "Developer Command Prompt for VS 2022" depending on your Visual Studio version.

From a (non-admin) Command Prompt window:

Expand All @@ -69,7 +118,7 @@ From a (non-admin) Command Prompt window:

### Cross compiling for ARM

You can use the Developer Command Prompt, Powershell or work in any regular cmd. The Developer Command Prompt will have a name like "Developer Command Prompt for VS 2019" or similar in your start menu.
You can use the Developer Command Prompt, Powershell or work in any regular cmd. The Developer Command Prompt will have a name like "Developer Command Prompt for VS 2019" or "Developer Command Prompt for VS 2022" depending on your Visual Studio version.

From a (non-admin) Command Prompt window based on what you want to target:

Expand Down Expand Up @@ -102,6 +151,11 @@ For more information on running ML.NET benchmarks, please visit the [benchmarkin

## Known Issues

CMake 3.14 or higher is required for Visual Studio 2019.
### CMake Version Compatibility
* CMake 3.14 or higher is required for Visual Studio 2019.
* CMake 3.21 or higher is required for Visual Studio 2022.
* CMake 4.2 or higher is required for Visual Studio 2026.
* CMake 4.0 and later versions are supported.

### Build Process
You need to run `build` from the root of the repo first prior to opening the solution file and building in Visual Studio.