Skip to content
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

MSVC: VS2019 is not recognized #367

Open
zosrothko opened this issue Dec 6, 2020 · 12 comments
Open

MSVC: VS2019 is not recognized #367

zosrothko opened this issue Dec 6, 2020 · 12 comments

Comments

@zosrothko
Copy link
Contributor

Hi

The latest VS2019 version of MSVC is not recognized by maven-nar-plugin because the Register Key is not updated anymore by MSVC installation starting from VS2019. See there. Thus nar-maven-plugin should use now the vswhere.exe to locate MSVC tools as linker & compiler.

@vindiagram
Copy link

vindiagram commented Jan 20, 2021

To add more to @zosrothko statement of the issue. VS 2019 does not set and "SOFTWARE\Microsoft\VisualStudio\SxS\VS7" registry keys nor does it set any "VS###COMNTOOLS" environment variables. The recommended approach from Microsoft is to use the vswhere.exe utility. This utility was added in VS 2017 and will always be installed to "C:\Program Files (x86)\Microsoft Visual Studio\Installer" no matter the configuration of VS 2017 or VS 2019 during installation.

Thus it should be simple to add a check for the tools existence and then perform its execution to locate the installations.

Example:
"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -all -products Microsoft.VisualStudio.Product.BuildTools -format json -utf8

Produces
[ { "instanceId": "7ac59f05", "installDate": "2021-01-13T14:09:11Z", "installationName": "VisualStudio/16.8.4+30907.101", "installationPath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools", "installationVersion": "16.8.30907.101", "productId": "Microsoft.VisualStudio.Product.BuildTools", "productPath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\Common7\\Tools\\LaunchDevCmd.bat", "state": 4294967295, "isComplete": true, "isLaunchable": true, "isPrerelease": false, "isRebootRequired": false, "displayName": "Visual Studio Build Tools 2019", "description": "The Visual Studio Build Tools allows you to build native and managed MSBuild-based applications without requiring the Visual Studio IDE. There are options to install the Visual C++ compilers and libraries, MFC, ATL, and C++/CLI support.", "channelId": "VisualStudio.16.Release", "channelUri": "https://aka.ms/vs/16/release/channel", "enginePath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\resources\\app\\ServiceHub\\Services\\Microsoft.VisualStudio.Setup.Service", "releaseNotes": "https://go.microsoft.com/fwlink/?LinkId=660893#16.8.4", "thirdPartyNotices": "https://go.microsoft.com/fwlink/?LinkId=660909", "updateDate": "2021-01-13T14:09:11.9659288Z", "catalog": { "buildBranch": "d16.8", "buildVersion": "16.8.30907.101", "id": "VisualStudio/16.8.4+30907.101", "localBuild": "build-lab", "manifestName": "VisualStudio", "manifestType": "installer", "productDisplayVersion": "16.8.4", "productLine": "Dev16", "productLineVersion": "2019", "productMilestone": "RTW", "productMilestoneIsPreRelease": "False", "productName": "Visual Studio", "productPatchVersion": "4", "productPreReleaseMilestoneSuffix": "1.0", "productSemanticVersion": "16.8.4+30907.101", "requiredEngineVersion": "2.8.3267.30329" }, "properties": { "campaignId": "", "channelManifestId": "VisualStudio.16.Release/16.8.4+30907.101", "nickname": "", "setupEngineFilePath": "C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\vs_installershell.exe" } } ]

This json could be parsed for the list of installed VS version since 2010.

see properties: InstallationPath, InstallationVersion

@mondain
Copy link
Contributor

mondain commented Feb 17, 2021

I just tried this with 3.10.1 and locally built 3.10.2-SNAPSHOT, neither work with or without a passed in proper path to the tools ie. mvn clean package -P win -Dmsvc.toolpath="C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64"

Always failing on validate

[ERROR] Failed to execute goal com.github.maven-nar:nar-maven-plugin:3.10.2-SNAPSHOT:nar-validate (default-nar-validate) on project foo: Execution default-nar-validate of goal com.github.maven-nar:nar-maven-plugin:3.10.2-SNAPSHOT:nar-validate failed: The system cannot find the file specified.

@mondain
Copy link
Contributor

mondain commented Feb 24, 2021

I've got a working fix for this in my fork; I fixed it by using the environmental variables since VS no longer makes the previously used registry entries. https://github.com/mondain/nar-maven-plugin

@nmwael
Copy link

nmwael commented Aug 5, 2021

@mondain could you get your fix to working with the latest released nar in maven?

IE the "mvn clean package -P win -Dmsvc.toolpath="C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64" ?

@nmwael
Copy link

nmwael commented Aug 5, 2021

UPDATE: seems this changes something however it gives me a nullpointer..
<plugin> <groupId>com.github.maven-nar</groupId> <artifactId>nar-maven-plugin</artifactId> <version>3.10.1</version> <extensions>true</extensions> <configuration> <linker> <name>mscv</name> <toolPath>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30037\bin\Hostx64\x64</toolPath> </linker>

Caused by: java.lang.NullPointerException
at com.github.maven_nar.Linker.getVersion (Linker.java:617)

Im probably missing some property

@nmwael
Copy link

nmwael commented Aug 5, 2021

Okay made a spelling mistake, linker name should be msvc.. this gives:

DEBUG] -- end configuration --
[DEBUG] linker original name: msvc
[DEBUG] aol_linker: msvc
[INFO] Using AOL: amd64-Windows-msvc
[DEBUG] -- Searching for usable VisualStudio
[DEBUG] Requested Linker version is ""
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.501 s
[INFO] Finished at: 2021-08-05T12:54:25+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.maven-nar:nar-maven-plugin:3.10.1:nar-validate (default-nar-validate) on project it0015-cpp-executable: Execution default-nar-validate of goal com.github.maven-nar:nar-maven-plugin:3.10.1:nar-validate failed: The system cannot find the file specified. -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.github.maven-nar:nar-maven-plugin:3.10.1:nar-validate (default-nar-validate) on project it0015-cpp-executable: Execution default-nar-validate of goal com.github.maven-nar:nar-maven-plugin:3.10.1:nar-validate failed: The system cannot find the file specified.
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-nar-validate of goal com.github.maven-nar:nar-maven-plugin:3.10.1:nar-validate failed: The system cannot find the file specified.
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:148)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: com.sun.jna.platform.win32.Win32Exception: The system cannot find the file specified.
at com.github.maven_nar.Msvc.visualStudioVS7SxS (Msvc.java:528)
at com.github.maven_nar.Msvc.initVisualStudio (Msvc.java:577)
at com.github.maven_nar.Msvc.init (Msvc.java:140)
at com.github.maven_nar.AbstractNarMojo.getMsvc (AbstractNarMojo.java:331)

Which obviously are wrong, since version should be 16.. Looks like something are different in the current master branch of the nar plugin, maybe it has been fixed there?

@nmwael
Copy link

nmwael commented Aug 5, 2021

Okay so I just tried to use version 3.10.2-SNAPSHOT built from master and it seems to be working (I get an error but it looks to be from the actually cpp code)

I wonder when are 3.10.2-SNAPSHOT scheduled to be released

@GregDomjan
Copy link
Member

@ctrueden do you have time to push the snapshot?

@mondain
Copy link
Contributor

mondain commented Oct 19, 2021

@nmwael @GregDomjan I've also had issues on newer Windows 10 systems if I've installed the VS 2019 build tools on top of VS 2019 itself; the paths get messed up etc, I've been able to resolve that by removing the build tools; not sure why MS even supports having both when one or the other isnt needed.

@GregDomjan
Copy link
Member

@mondain haven't really had time to look into such a configuration of the system with the IDE and Build tools, think there is a similar assumption that you can only have either enterprise or professional and not both.

@mondain
Copy link
Contributor

mondain commented Apr 8, 2022

@GregDomjan @ctrueden did the plugin updates get pushed somewhere? Switching my pom when I have to build on windows systems still requires me to build the plugin itself to proceed; which is of course a PITA going on ~4 months now...

@GregDomjan
Copy link
Member

@mondain Sorry no progress from my side, will look into it some more soon I hope

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants