Enable build with Visual Studio 2017#2390
Conversation
This version is the first version that supports generating a project using the Visual Studio 2017 toolchain.
|
@jkotas I had to update the minimum CMake version to 3.7.0 to enable compilation with VS2017, as earlier versions don't support that version of VS. However, I presume that the CI machines don't have this version of VS installed, as all 6 checks failed as I was writing this. However, this version is only required when building for VS2017; earlier versions (or non-VS build systems) will still work with the older version previously used. Unfortunately, I don't know how to express this in CMake. Could you give me a few pointers? Thanks! |
|
In addition, I cannot yet successfully build CoreRT using VS2017, because when the build script sources |
|
Try something like: |
Can we just use this version of CMake that comes with VS2017? Or is it not possible for some reason? |
|
@jkotas According to the CMake website, CMake 3.7.0 is the minimum required version for VS2017 support. I will test on the version of CMake that is bundled, however. I have researched how to check the generator being used, and will push a commit later tonight that only requires a higher CMake version when targeting VS2017. |
Unfortunately, the generated solution then does not build correctly. I am still looking into this.
The code previously assumed that the probe-win.ps1 script is located in the current working directory. During my testing, I found that this is not robust enough for all use-cases. Using %~dp0 to identify the directory containing the batch file is more robust against this issue.
|
@jkotas Note: The Ubuntu builds are currently failing with the following message:
I don't know what this means, but it seems unrelated to these changes. |
|
I have fixed the build to function correctly using the CMake version included with VS2017. I have adjusted the version check to 3.6.0 accordingly. However, I am running into a very strange issue: When the Visual Studio files generated by CMake are built by the automated |
Only the copy of MSBuild shipped with VS2017 can successfully build VS2017 vcxproj files. Using any other copy will cause strange errors.
|
My latest commit fixes the problem mentioned in my comment above regarding the PlatformToolset; please disregard that. |
|
And the CoreRT build cycle (native and managed) completes successfully on my computer with no issues! I think this one may be ready to merge. Note that the CI system won't test these changes, as this is an optional feature that must be explicitly enabled by the user. |
This is cascading error. The primary error is: |
|
Also, if I just fetch your branch and run "build.cmd", it fails with: |
Third time's the charm, right?
This should fix the problem @jkotas is reporting, but I cannot be certain.
|
@jkotas Try it now. I have fixed the Ubuntu build issue, and I should have fixed the issue you are having. (I have confirmed that it no longer complains of the issue you reported, but I cannot make that specific configuration build on my PC. This is because the only version of CMake I have now is the one in VS2017; I uninstalled the other because I didn't think I would need it anymore.) Sorry about that! |
|
This batch file variable is still misbehaving if I do "build.cmd vs2017". Here is output with |
|
@janvorli Could you please take a look at the CMake changes? |
|
|
||
| set __VSProductVersion= | ||
| if /i "%__VSVersion%" == "vs2015" set __VSProductVersion=140 | ||
| if /i "%__VSVersion%" == "vs2017" set __VSProductVersion=150 |
There was a problem hiding this comment.
It would be nice to mention vs2017 in the help text at the end of the file.
There was a problem hiding this comment.
|
@jkotas Regarding those drive-not-found errors: I've seen those, and have no idea what is causing them. Since they seem to have no effect on the build, I was ignoring them, but I understand how they should be corrected before this PR is merged. I will get on the documentation sometime tomorrow. |
src/Native/CMakeLists.txt
Outdated
| # Include cmake functions | ||
| include(functions.cmake) | ||
|
|
||
| string_has_prefix(${CMAKE_GENERATOR} "Visual Studio 15 2017" GENERATOR_IS_VS2017) |
There was a problem hiding this comment.
You don't need to introduce a new function. string(FIND ${CMAKE_GENERATOR} "Visual Studio 15 2017" VS2017_POS) and comparing VS2017_POS to 0 would work for this purpose.
There was a problem hiding this comment.
@janvorli Thank you! For some reason I couldn't find that in the documentation. I will get that fixed later today.
buildscripts/build-native.cmd
Outdated
|
|
||
| :: VS2017 changed the location of vcvarsall.bat. | ||
| if /i "%__VSVersion%" == "vs2017" ( | ||
| call "!VS%__VSProductVersion%COMNTOOLS!\..\..\VC\Auxiliary\Build\vcvarsall.bat" %__VCBuildArch% |
There was a problem hiding this comment.
Just to be precise, how many spaces?
They are caused by the |
The Windows batch file interpreter treats these two symbols differently. When "::" is used within an if block, it can create spurious drive-not-found errors. Using "rem" avoids this problem.
|
Thank you! |
This is a followup to dotnet#2390 that fixes a few things: * vs2017 no longer needs to be passed to build.cmd (it will be autodetected) * Building and running tests now works * Documentation updates to point out running from Developer Command prompt is needed. Fixes dotnet#3394.
This PR enables building (the native parts of) CoreRT using Visual Studio 2017 RC.
Closes #2383.