Skip to content

Commit b0fdb44

Browse files
authored
These changes allow for ML.NET to be built from source by VS2019 (dotnet#3742)
* These changes allow for ML.NET to be built from source by VS2019 * Updates to files as per comments on pull request * Add support for x86 since VS 2019 project generator doesn't default to x86 anymore
1 parent 3fb7256 commit b0fdb44

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

docs/building/windows-instructions.md

+9-7
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,35 @@ You can build ML.NET either via the command line or by using Visual Studio.
55

66
## Required Software
77

8-
1. **[Visual Studio 2017](https://www.visualstudio.com/downloads/) (Community, Professional, Enterprise)** The Community version is completely free. The below build instructions were verified for VS 15.8.0 and higher.
8+
1. **[Visual Studio 2019 / Visual Studio 2017](https://www.visualstudio.com/downloads/) (Community, Professional, Enterprise)** The Community version is completely free. The below build instructions were verified for VS 15.8.0 and higher.
99
2. **[CMake](https://cmake.org/)** must be installed from [the CMake download page](https://cmake.org/download/#latest) and added to your path.
1010

11-
### Visual Studio 2017 Installation
11+
### Visual Studio 2019 / Visual Studio 2017 Installation
1212
We have successfully verified the below build instructions for Visual Studio version 15.8.0 and higher.
1313

14-
#### Visual Studio 2017 - 'Workloads' based install
14+
#### Visual Studio 2019 / Visual Studio 2017 - 'Workloads' based install
1515

1616
The following are the minimum requirements:
1717
* .NET desktop development
1818
* All Required Components
1919
* .NET Framework 4-4.6 Development Tools
2020
* Desktop development with C++
2121
* All Required Components
22-
* VC++ 2017 v141 Toolset (x86, x64)
22+
* VC++ 2019 v142 Toolset (x86, x64) for Visual Studio 2019 or VC++ 2017 v141 Toolset (x86, x64) for Visual Studio 2017
2323
* Windows 8.1 SDK and UCRT SDK
2424
* .NET Core cross-platform development
2525
* All Required Components
2626

2727
Note: If you have both VS 2017 and 2015 installed, you need to copy DIA SDK directory from VS 2015 installation into VS 2017 (VS installer bug).
2828

29-
#### Visual Studio 2017 - 'Individual components' based install
29+
#### Visual Studio 2019 / Visual Studio 2017 - 'Individual components' based install
3030

3131
The following are the minimum requirements:
3232
* C# and Visual Basic Roslyn Compilers
3333
* Static Analysis Tools
3434
* .NET Portable Library Targeting Pack
3535
* Visual Studio C++ Core Features
36-
* VC++ 2017 v141 Toolset (x86, x64)
36+
* VC++ 2019 v142 Toolset (x86, x64) for Visual Studio 2019 or VC++ 2017 v141 Toolset (x86, x64) for Visual Studio 2017
3737
* MSBuild
3838
* .NET Framework 4.6 Targeting Pack
3939
* Windows Universal CRT SDK
@@ -42,7 +42,7 @@ The following are the minimum requirements:
4242

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

45-
### Building From Visual Studio 2017
45+
### Building From Visual Studio 2019 / Visual Studio 2017
4646

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

@@ -77,4 +77,6 @@ For more details, or to test an individual project, you can navigate to the test
7777

7878
CMake 3.7 or higher is required for Visual Studio 2017.
7979

80+
CMake 3.14 or higher is required for Visual Studio 2019.
81+
8082
You need to run `build` from the root of the repo first prior to opening the solution file and building in Visual Studio.

src/Native/build.cmd

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ exit /b 1
6464
:VS2019
6565
:: Setup vars for VS2019
6666
set __PlatformToolset=v142
67-
set __VSVersion=15 2017
67+
set __VSVersion=16 2019
6868
if NOT "%__BuildArch%" == "arm64" (
6969
:: Set the environment for the native build
7070
call "%VS160COMNTOOLS%..\..\VC\Auxiliary\Build\vcvarsall.bat" %__VCBuildArch%

src/Native/gen-buildsys-win.bat

+6-5
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,12 @@ if %1=="/?" GOTO :USAGE
1111
setlocal
1212
set __sourceDir=%~dp0
1313

14+
set __ExtraCmakeParams=
15+
1416
set __VSString=%2
1517
:: Remove quotes
1618
set __VSString=%__VSString:"=%
1719

18-
:: Set the target architecture to a format cmake understands.
19-
if /i "%3" == "x86" (set __VSString=%__VSString%)
20-
if /i "%3" == "x64" (set __VSString=%__VSString% Win64)
2120

2221
if defined CMakePath goto DoGen
2322

@@ -27,14 +26,16 @@ for /f "delims=" %%a in ('powershell -NoProfile -ExecutionPolicy ByPass "& .\pro
2726
popd
2827

2928
:DoGen
30-
"%CMakePath%" "-DCMAKE_BUILD_TYPE=%CMAKE_BUILD_TYPE%" "-DCMAKE_INSTALL_PREFIX=%__CMakeBinDir%" "-DMKL_LIB_PATH=%MKL_LIB_PATH%" -G "Visual Studio %__VSString%" -B. -H%1
29+
if /i "%3" == "x64" (set __ExtraCmakeParams=%__ExtraCmakeParams% -A x64)
30+
if /i "%3" == "x86" (set __ExtraCmakeParams=%__ExtraCmakeParams% -A Win32)
31+
"%CMakePath%" "-DCMAKE_BUILD_TYPE=%CMAKE_BUILD_TYPE%" "-DCMAKE_INSTALL_PREFIX=%__CMakeBinDir%" "-DMKL_LIB_PATH=%MKL_LIB_PATH%" -G "Visual Studio %__VSString%" %__ExtraCmakeParams% -B. -H%1
3132
endlocal
3233
GOTO :DONE
3334

3435
:USAGE
3536
echo "Usage..."
3637
echo "gen-buildsys-win.bat <VSVersion> <Target Architecture>"
37-
echo "Specify the VSVersion to be used - VS2015 or VS2017"
38+
echo "Specify the VSVersion to be used - VS2015, VS2017 or VS2019"
3839
echo "Specify the Target Architecture - x86, or x64."
3940
EXIT /B 1
4041

0 commit comments

Comments
 (0)