I have recently upgraded my Cordova solution to work with Visual Studio 2017. I am able to successfully build Android APKs from within the Visual Studio Professional 2017 IDE.
When I try to build the solution using MSBuild 2017 from the command line, I receive the following error:
MSBUILD : cordova-build error BLDErr_Build_ExceptionLookingForNode: Unable to determine location of Node.js installation. Exception: Could not load file or assembly 'Microsoft.VisualStudio.Setup.Engine, Version=1.0.0.0, Culture=neutral, Pu blicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. [C:\dev\Common\Source\Mobile-NGC\PhalanxNGC.jsproj]
I have tried it when using Node.js v4.8.4 and v6.11.3, as well as 32-bit and 64-bit versions but with no success.
I have also looked for the Microsoft.VisualStudio.Setup.Engine.dll and I can find it in the IDE directory:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\PrivateAssemblies\Microsoft.VisualStudio.Setup.Engine.dll
I am unable to find it under the MSBuild directory.
Any help would be appreciated. Thanks.
Edit: To clarify, the MSBuild I am using is the "Build Tools for Visual Studio 2017" downloaded from https://www.visualstudio.com/downloads/.
It is installed in C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin
The MSBuild command I am using is:
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBUILD.exe /nologo /p:Configuration=Debug /verbosity:diag C:\dev\Common\Source\Mobile-NGC\NGC.sln
Edit2: After comparing the failing MSBuild CLI output with the successful IDE build output, I can see that the property NodeJsDir is not logged for the failed CLI MSBuild.
This is the line from the successful build log:
NodeJsDir = C:\ProgramData\Microsoft\VisualStudio\MDA\8430d60a\taco-toolset-6.3.1
Edit3: It looks as though other Environment Variables for Tools for Apache Cordova are missing from the failing build log. These include: NODEJSDIR, NPMINSTALLDIR, LANGNAME, BUILDVERBOSITY, GIT_HOME.
Update: I have reported this to Microsoft support and it is now logged as an issue. The work around for now is to build using devenv from the command line:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\devenv.com [PathToCordovaSolution] "Debug|Android"