From b0fdb444a4acaf402c706dcbeaf157eb2668ccd3 Mon Sep 17 00:00:00 2001 From: PranovD Date: Fri, 17 May 2019 12:55:14 -0700 Subject: [PATCH] These changes allow for ML.NET to be built from source by VS2019 (#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 --- docs/building/windows-instructions.md | 16 +++++++++------- src/Native/build.cmd | 2 +- src/Native/gen-buildsys-win.bat | 11 ++++++----- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/docs/building/windows-instructions.md b/docs/building/windows-instructions.md index 0ba451adf9..60f763b239 100644 --- a/docs/building/windows-instructions.md +++ b/docs/building/windows-instructions.md @@ -5,13 +5,13 @@ You can build ML.NET either via the command line or by using Visual Studio. ## Required Software -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. +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. 2. **[CMake](https://cmake.org/)** must be installed from [the CMake download page](https://cmake.org/download/#latest) and added to your path. -### Visual Studio 2017 Installation +### Visual Studio 2019 / Visual Studio 2017 Installation We have successfully verified the below build instructions for Visual Studio version 15.8.0 and higher. -#### Visual Studio 2017 - 'Workloads' based install +#### Visual Studio 2019 / Visual Studio 2017 - 'Workloads' based install The following are the minimum requirements: * .NET desktop development @@ -19,21 +19,21 @@ The following are the minimum requirements: * .NET Framework 4-4.6 Development Tools * Desktop development with C++ * All Required Components - * VC++ 2017 v141 Toolset (x86, x64) + * VC++ 2019 v142 Toolset (x86, x64) for Visual Studio 2019 or VC++ 2017 v141 Toolset (x86, x64) for Visual Studio 2017 * Windows 8.1 SDK and UCRT SDK * .NET Core cross-platform development * All Required Components 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). -#### Visual Studio 2017 - 'Individual components' based install +#### Visual Studio 2019 / Visual Studio 2017 - 'Individual components' based install The following are the minimum requirements: * C# and Visual Basic Roslyn Compilers * Static Analysis Tools * .NET Portable Library Targeting Pack * Visual Studio C++ Core Features - * VC++ 2017 v141 Toolset (x86, x64) + * VC++ 2019 v142 Toolset (x86, x64) for Visual Studio 2019 or VC++ 2017 v141 Toolset (x86, x64) for Visual Studio 2017 * MSBuild * .NET Framework 4.6 Targeting Pack * Windows Universal CRT SDK @@ -42,7 +42,7 @@ The following are the minimum requirements: 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 2017 +### Building From Visual Studio 2019 / Visual Studio 2017 First, set up the required tools, from a (non-admin) Command Prompt window: @@ -77,4 +77,6 @@ For more details, or to test an individual project, you can navigate to the test CMake 3.7 or higher is required for Visual Studio 2017. +CMake 3.14 or higher is required for Visual Studio 2019. + You need to run `build` from the root of the repo first prior to opening the solution file and building in Visual Studio. diff --git a/src/Native/build.cmd b/src/Native/build.cmd index 1454f47fd0..0a46ed07d6 100644 --- a/src/Native/build.cmd +++ b/src/Native/build.cmd @@ -64,7 +64,7 @@ exit /b 1 :VS2019 :: Setup vars for VS2019 set __PlatformToolset=v142 -set __VSVersion=15 2017 +set __VSVersion=16 2019 if NOT "%__BuildArch%" == "arm64" ( :: Set the environment for the native build call "%VS160COMNTOOLS%..\..\VC\Auxiliary\Build\vcvarsall.bat" %__VCBuildArch% diff --git a/src/Native/gen-buildsys-win.bat b/src/Native/gen-buildsys-win.bat index 0750995dcf..78f42a9f78 100644 --- a/src/Native/gen-buildsys-win.bat +++ b/src/Native/gen-buildsys-win.bat @@ -11,13 +11,12 @@ if %1=="/?" GOTO :USAGE setlocal set __sourceDir=%~dp0 +set __ExtraCmakeParams= + set __VSString=%2 :: Remove quotes set __VSString=%__VSString:"=% -:: Set the target architecture to a format cmake understands. -if /i "%3" == "x86" (set __VSString=%__VSString%) -if /i "%3" == "x64" (set __VSString=%__VSString% Win64) if defined CMakePath goto DoGen @@ -27,14 +26,16 @@ for /f "delims=" %%a in ('powershell -NoProfile -ExecutionPolicy ByPass "& .\pro popd :DoGen -"%CMakePath%" "-DCMAKE_BUILD_TYPE=%CMAKE_BUILD_TYPE%" "-DCMAKE_INSTALL_PREFIX=%__CMakeBinDir%" "-DMKL_LIB_PATH=%MKL_LIB_PATH%" -G "Visual Studio %__VSString%" -B. -H%1 +if /i "%3" == "x64" (set __ExtraCmakeParams=%__ExtraCmakeParams% -A x64) +if /i "%3" == "x86" (set __ExtraCmakeParams=%__ExtraCmakeParams% -A Win32) +"%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 endlocal GOTO :DONE :USAGE echo "Usage..." echo "gen-buildsys-win.bat " - echo "Specify the VSVersion to be used - VS2015 or VS2017" + echo "Specify the VSVersion to be used - VS2015, VS2017 or VS2019" echo "Specify the Target Architecture - x86, or x64." EXIT /B 1