Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Commit

Permalink
Support building corefx in VS2019
Browse files Browse the repository at this point in the history
  • Loading branch information
safern committed Feb 9, 2019
1 parent bb6dc56 commit 4bfd00f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Documentation/building/windows-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Building CoreFX on Windows

1. **[Visual Studio 2017](https://www.visualstudio.com/downloads/)** (Community, Professional, Enterprise) with the latest update must be installed. The Community version is completely free.
2. **[.NET Core SDK](https://www.microsoft.com/net/download/windows)** >= v2.1.401 must be installed which will add the `dotnet` toolchain to your path.
3. **[CMake](https://cmake.org/)** must be installed from [the CMake download page](https://cmake.org/download/#latest) and added to your path.
3. **[CMake](https://cmake.org/)** must be installed from [the CMake download page](https://cmake.org/download/#latest) and added to your path. CMake 3.14 or later is required to build with VS 2019.

### Visual Studio 2017

Expand Down
29 changes: 20 additions & 9 deletions src/Native/Windows/gen-buildsys-win.bat
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,29 @@ for %%x in (%*) do Set /A argC+=1
if NOT %argC%==3 GOTO :USAGE
if %1=="/?" GOTO :USAGE

setlocal
setlocal EnableDelayedExpansion
set __sourceDir=%~dp0
set __ExtraCmakeParams=

:: VS 2017 is required to build native assets,
:: once CMake supports 2019 as the project generator we can use that if installed in the local system
set __VSString=15 2017
:: VS 2017 is the minimum supported toolset
if "%__VSVersion%" == "vs2019" (
set __VSString=16 2019

:: Set the target architecture to a format cmake understands. ANYCPU defaults to x64
if /i "%3" == "x86" (set __VSString=%__VSString%)
if /i "%3" == "x64" (set __VSString=%__VSString% Win64)
if /i "%3" == "arm" (set __VSString=%__VSString% ARM)
:: VS 2019 generator is not per arch, and the arch needs to be passed with -A option
:: x86 is the default arch selected by cmake.
:: CMAKE 3.14 or later is required to use VS2019
if /i "%3" == "x64" (set __ExtraCmakeParams=%__ExtraCmakeParams% -A x64)
if /i "%3" == "arm" (set __ExtraCmakeParams=%__ExtraCmakeParams% -A ARM)
) else (
set __VSString=15 2017

:: VS2017 generator needs to be specified with the arch as part of its name.
:: x86 is the default arch selected by cmake.
if /i "%3" == "x64" (set __VSString=!__VSString! Win64)
if /i "%3" == "arm" (set __VSString=!__VSString! ARM)
)

:: arm64 doesn't have a specific generator so we need to pass it through -A option.
if /i "%3" == "arm64" (set __ExtraCmakeParams=%__ExtraCmakeParams% -A ARM64)
if /i "%3" == "wasm" (set __sourceDir=%~dp0..\Unix && goto DoGen)

Expand All @@ -35,7 +46,7 @@ popd
if "%3" == "wasm" (
emcmake cmake "-DEMSCRIPTEN_GENERATE_BITCODE_STATIC_LIBRARIES=1" "-DCMAKE_TOOLCHAIN_FILE=%EMSCRIPTEN%/cmake/Modules/Platform/Emscripten.cmake" "-DCMAKE_BUILD_TYPE=%CMAKE_BUILD_TYPE%" -G "NMake Makefiles" %__sourceDir%
) else (
"%CMakePath%" %__SDKVersion% "-DCMAKE_BUILD_TYPE=%CMAKE_BUILD_TYPE%" "-DCMAKE_INSTALL_PREFIX=%__CMakeBinDir%" -G "Visual Studio %__VSString%" -B. -H%1 %__ExtraCmakeParams%
"%CMakePath%" %__SDKVersion% "-DCMAKE_BUILD_TYPE=%CMAKE_BUILD_TYPE%" "-DCMAKE_INSTALL_PREFIX=%__CMakeBinDir%" -G "Visual Studio %__VSString%" -B. -H%1 %__ExtraCmakeParams%
)
endlocal
GOTO :DONE
Expand Down
4 changes: 2 additions & 2 deletions src/Native/build-native.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ exit /b 1
:VS2019
:: Setup vars for VS2019
set __VSVersion=vs2019
set __PlatformToolset=v141
set __PlatformToolset=v142
:: Set the environment for the native build
call "%VS160COMNTOOLS%..\..\VC\Auxiliary\Build\vcvarsall.bat" %__VCBuildArch%
goto :SetupDirs
Expand Down Expand Up @@ -120,7 +120,7 @@ echo Error: DIA SDK is missing at "%VSINSTALLDIR%DIA SDK". ^
Make sure you selected the correct dependencies when installing Visual Studio.
:: DIA SDK not included in Express editions
echo Visual Studio Express does not include the DIA SDK. ^
You need Visual Studio 2015 or 2017 (Community is free).
You need Visual Studio 2017 or 2019 (Community is free).
echo See: https://github.com/dotnet/corefx/blob/master/Documentation/building/windows-instructions.md#required-software
exit /b 1

Expand Down

0 comments on commit 4bfd00f

Please sign in to comment.