Skip to content

ML.net build failing with Visual Studio 2019 Version 16.0 #1967

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Anipik opened this issue Dec 24, 2018 · 13 comments
Closed

ML.net build failing with Visual Studio 2019 Version 16.0 #1967

Anipik opened this issue Dec 24, 2018 · 13 comments
Assignees
Labels
Build Build related issue
Milestone

Comments

@Anipik
Copy link
Contributor

Anipik commented Dec 24, 2018

I just rebooted my machine. So while setting up the visual studio, I installed the latest Visual Studio 2019.
The visual studio version for this 16.0

So when I try to build the repo, I get an error as
Error: Visual Studio 2015 or 2017 required.

My guess is that the problem is here
https://github.com/dotnet/machinelearning/blob/master/src/Native/build.cmd#L48

This check fails as the value of the version is 16.0

I changed this line to
if %VisualStudioVersion% geq 15.0 (

and the build works fine then.

is this an appropriate fix and anything else also needs to be done here ?

cc @danmosemsft @safern @eerhardt @TomFinley

@codemzs
Copy link
Member

codemzs commented Dec 24, 2018

You may want to do an explicit equality comparison like we do for VS 2015 and VS 2017, not just greater than equal to, what if another version gets released that needs to have different setup?, in addition to that you may want to consider changing/adding few more things, for example, change the error message here below:

:MissingVersion
:: Can't find VS 2015 or 2017
echo Error: Visual Studio 2015 or 2017 required
echo Please see https://github.com/dotnet/machinelearning/tree/master/Documentation for build instructions.
exit /b 1

Just like how we have setup lines for VS2017, we probably will need something for VS 2019, no?
:VS2017
:: Setup vars for VS2017
set __PlatformToolset=v141
set __VSVersion=15 2017
if NOT "%__BuildArch%" == "arm64" (
:: Set the environment for the native build
call "%VS150COMNTOOLS%....\VC\Auxiliary\Build\vcvarsall.bat" %__VCBuildArch%
)
goto :SetupDirs

All in all, we need to have explicit references for VS 2019 just like we have for VS 2017/2015.

@Anipik
Copy link
Contributor Author

Anipik commented Dec 25, 2018

Actually i tried changing i to set __VSVersion=16 2019 for 2019 VS but cmake fails to recognise it and i get this as an error

EXEC : CMake error : Could not create named generator Visual Studio 16 2019 Win64 [C:\git\machinelearning\src\Native\build.proj]

i am not sure whts the correct set of values for vsversion and platformToolset for vs2019

@rrmistry
Copy link

If you're trying to build using build.cmd on Windows (at the root level of this repository) then there is a much simpler fix.

I traced down the call sequence to:

  1. .\build.cmd
  2. src\Native\build.cmd
  3. %ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe

The relevant parameters for vswhere.exe are:

-prerelease    Also searches prereleases. By default, only releases are searched.
-version arg   A version range for instances to find. Example: [15.0,16.0) will find versions 15.*.
-latest        Return only the newest version and last installed.

Making an inferrence on this, when I changed this file:

for /f "usebackq tokens=*" %%i in (`%_VSWHERE% -latest -prerelease -property installationPath`) do set _VSCOMNTOOLS=%%i\Common7\Tools

And removed the -prerelease cmd argument, it defaulted to VS 2017.

This is obviously a temporary solution until VS 2019 becomes an official version, but then ML.NET might move to VS 2019 anyways 😏

@Anipik
Copy link
Contributor Author

Anipik commented Dec 25, 2018

Actually there is no vs 2017 on my machine

@rrmistry
Copy link

Actually there is no vs 2017 on my machine

Just to be safe, it would be best to install VS 2017. Just to ensure consistent behavior with other developers. VS 2019 may have different sets of C++ optimizations so you won't be reproducing the exact build / test environment as intended by authors.

@TomFinley
Copy link
Contributor

TomFinley commented Dec 25, 2018

Just to be safe, it would be best to install VS 2017. Just to ensure consistent behavior with other developers. VS 2019 may have different sets of C++ optimizations so you won't be reproducing the exact build / test environment as intended by authors.

This issue here (until properly investigated) is what would lead me to prefer a VS 2019 build being something a user has to explicitly invoke, with the default behavior being to insist on the older version. Over the years, as we've moved from one version of VS to the next, it was the inconsistency of native code from one compilation to the next and the resulting change in expected values in tests that was the biggest barrier to new VS adoption. (To be clear, I don't know that VS 2019 will give us the same problem. But, if it doesn't, it would be the first version of VS that did not. Guilty until proven innocent, and whatnot. 😉)

But for now, while making VS 2019 compilation possible, should we keep that as something the user has to explicitly flag, if they want to use? So, if VS 2017 and 2019 pre-release are both on the machine, it defaults to 2017, if only 2019 then it complains, and in either situation it compiles on 2019 if the flag is set? What you think @Anipik and @rrmistry, good idea, bad idea?

@rrmistry
Copy link

I would prefer the same. No objections on my part for:

if VS 2017 and 2019 pre-release are both on the machine, it defaults to 2017, if only 2019 then it complains, and in either situation it compiles on 2019 if the flag is set

where a new flag is required to be implemented for the build / tools / run batch scripts.

Sure would make debugging things a lot easier too when the project is officially planned to move to VS 2019.

@rrmistry
Copy link

By the way, I just wanted to convey my sincere thanks for all the hard work that everyone has been putting into this project. And wish everybody a very Merry Christmas! 🎄

@TomFinley , I have never contributed to a open source project before, but I would like to start.

I did read through CONTRIBUTING.md but I'm not sure what's the best way to handle this.

I can offer to do a deeper investigation and produce findings as suggested, or go through ROADMAP.md and offer support towards greatest needs.

We can connect in private over gitter if you would like. Any tips or advise would be much obliged 🤠

Again, thanks for everything!

@Anipik
Copy link
Contributor Author

Anipik commented Dec 27, 2018

Yes @TomFinley I agree with you. We will have to fix the compile for for 2019

@safern
Copy link
Member

safern commented Dec 27, 2018

This is what I did in core fix to fix this: dotnet/corefx#33969 we use a very similar mechanism so you could use that as a guidance.

@codemzs
Copy link
Member

codemzs commented Dec 27, 2018

Thanks @safern , this is what I was expecting the fix to be.

@TomFinley
Copy link
Contributor

TomFinley commented Dec 27, 2018

Great, thanks all, and thanks to you @rrmistry ! This is a great attitude. I'm not an expert in the build systems but @safern definitely is. 😄 Though, this time of year most people are on vacation so maybe we won't be as responsive as some other times. Not sure if you wanted to tackle it?

@rrmistry
Copy link

Thanks @TomFinley ! I'm on-and-off the holiday spirits myself 🎄 🎁 🎆
I'll reach out to @safern to discuss best way to move forward. Thanks!

@shauheen shauheen added this to the 0219 milestone Feb 6, 2019
@shauheen shauheen added the Build Build related issue label Feb 6, 2019
@ghost ghost locked as resolved and limited conversation to collaborators Mar 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Build Build related issue
Projects
None yet
Development

No branches or pull requests

7 participants