Ionic / Cordova Windows build picking up incorrect MSBUILD path - visual-studio

I have had to do a few update of Visual Studio on my Windows 10 machine (after some licensing issues).
I use to have Visual Studio Enterprise 2017, which I uninstalled. I now have Visual Studio Professional 2017, and Studio Enterprise 2019 (which I recently installed). I also installed Visual Studio Build Tools 2019 (2).
Now, when I try to build my Ionic project via the command I have always used...
ionic cordova build windows --prod --release -- --archs="x86 x64 arm" --buildConfig=platform_build_files\\windows\\build.config
I now get the error...
Building project: D:\dev\myapp\platforms\windows\CordovaApp.Windows10.jsproj
Configuration : release
Platform : x86
Buildflags : /p:AppxBundle=Never,/p:UapAppxPackageBuildMode=StoreUpload
MSBuildTools : C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin
buildProject spawn: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\msbuild [ 'D:\\dev\\myapp\\platforms\\windows\\CordovaApp.Windows10.jsproj', '/clp:NoSummary;NoItemAndPropertyList;Verbosity=minimal',
'/nologo',
'/p:Configuration=release',
'/p:Platform=x86',
'/p:AppxBundle=Never',
'/p:UapAppxPackageBuildMode=StoreUpload' ] { stdio: 'inherit' }
The system cannot find the path specified.
No valid MSBuild was detected for the selected target: Error: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\msbuild: Command failed with exit code ENOENT
Of course I no longer have a folder C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise as I uninstalled it.
I have removed and readded the windows platform for my Ionic app, but this did not help.
Also, I am not sure if this is related, but when I try to open the CordovaApp.sln in Visual Studio 2019, I get the following...
Not sure if related.
My question is, how can I reset this MSBuild path? I cannot see any environmental variables anywhere for this, I just can't get rid of this old path
Edit 1
I added the env var as suggested:
Opened a new command prompt, but it is still looking for the non-existent path
No valid MSBuild was detected for the selected target: Error: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\msbuild: Command failed with exit code ENOENT

In Visual Studio 2019, creating UWP apps using Javascript is no longer supported, if you want to build UWP apps using web technologies like Cordova. You need to use Visual Studio 2017.
My question is, how can I reset this MSBuild path?
Visual Studio will choose the version of MSBuild without explicit settings, but you can change this by setting environment variables.
Please add the path of MSBuild to the system environment variable, like:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin
Best regards.

Related

MS-Build returning the visual studio installation path

How can the entry
<MsTestExePath>$(MSBuildProgramFiles32)Microsoft Visual Studio 14.0\Common7\IDE\mstest.exe</MsTestExePath>
in a .proj file be generalised, such that the build works for different licenses of Visual Studio 2019 as well, where mstest.exe is located at
C:\Program Files (x86)\Microsoft Visual
Studio\2019\Enterprise\Common7\IDE\MSTest.exe
in the case of an enterprise license?
The most generic solution may be to replace the variable parts of the path with msbuild macros, but which ones would that be?
According to this documentation,
The macro
$(VSInstallDir)
returns the path to the installation folder of the Visual Studio version currently used.
The following entry should therefore work for all versions of visual studio, for which mstest.exe is located in the subfolder \Common7\IDE\ under the installation directory:
<MsTestExePath>$(VSInstallDir)Common7\IDE\mstest.exe</MsTestExePath>

Build Failed after adding Kapsel Plugins to Cordova Project - Could not find SDK "Microsoft.VCLibs, Version=12.0"

I'm trying to make a Windows Cordova build using cmd but I'm getting below errors. Can any of you please guide me on how to fix this issue.
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(
2377,5): error MSB3774: Could not find SDK "Microsoft.VCLibs, Version=12.0".
No valid MSBuild was detected for the selected target: Error: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\msbuild.exe: Command failed with exit code 1
PS: I'm using Visual Studio Community 2017.

Build with sdk 7.1 on VS2015

I have Visual Studio 2015 installed, and I need to compile a specific project with Visual C++ 2010 compiler, which is included in SDK 7.1.
I want to use 2010 compiler within VS2015, without install VS2010.
So, I installed it (the SDK), and "Visual Studio 2010 (v100)", "Windows7.1SDK" options appear under "Platform Toolset" property in the project properties.
But, when I try to build the project, I get those errors:
With "Windows7.1SDK" -
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\x64\Microsoft.Cpp.x64.Targets(146,5): error : Required file "" is missing.
and with "Visual Studio 2010 (v100)" -
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(297,5): warning MSB8003: Could not find WindowsSDKDir variable from the registry. TargetFrameworkVersion or PlatformToolset may be set to an invalid version number.
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\x64\Microsoft.Cpp.x64.Targets(146,5): error : Required file "" is missing.
Can't figure out what the problem is..
I had the same issue for 2 weeks and just found a workaround that might help :
Without modifying anything to my VS2010 projects (not changing the toolset in the vcxproj), I use the command line build tools MSBuild tools with the toolset specified as a switch as found here Building C++ project on a PC with Windows SDK 7.1 but without VS2010
msbuild /p:PateformToolset=Windows7.1SDK project.vcxproj
(In my case, the corresponding msbuild is in the folder C:\Windows\Microsoft.NET\Framework\v4.0.30319)
If Msbuild throws an error telling its missing mspdb100.dll, you may need to add %PROGRAMFILES(X86)%\Microsoft Visual Studio 10.0\Common7\IDE\ to your %PATH% env var.
Finally, you may have some files missing like ammintrin.h (especially if like me you try to compile old InDesign plugins) even after installing the visual c++ updates.
The only (and ugly) workaround I found in my case that does not involve installing VS2010 (the common answer of MS) is to copy the missing includes from the %PROGRAMFILES(X86)%\Microsoft Visual Studio 14.0\VC\include folder to the %PROGRAMFILES(X86)%\Microsoft Visual Studio 10.0\VC\include one.
Voila ! Hope this helps

`npm install weak` on Windows 8.1: error MSB8007: The Platform for project 'weakref.vcxproj' is invalid

Does anybody know why I'm getting:
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.Cpp.InvalidPlatform.Targets(23,7): error MSB8007: The Platform for project 'weakref.vcxproj' is invalid. Platform='x64'. You may be seeing this message because you are trying to build a project without a solution file, and have specified a non-default Platform that doesn't exist for this project. [C:\Users\mark\Desktop\myapp\node_modules\weak\build\weakref.vcxproj]
when attempting to npm install weak on Windows 8.1?
I tried installing Visual Studio C++ 2010 Express, adding C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcpackages as an environment variable and running npm install weak from the Visual Studio Command Prompt (2010) to no avail.
I've also installed the Windows 8.1 SDK but it doesn't seem to ship with a command prompt so I'm not really sure what to do there.

Visual Studio Empty Cordova Multi Device Hybrid App Build Failure [error code 8]

Having tried to follow all advices, remedies and workarounds including removing and reinstalling the Multi-Device Hybrid Apps for Visual Studio CPT1 I still can't seem to do a successful build of the included "Blank App (Apache Cordova)" project.
Build ends consistently in one single error:
The command ""C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7
\IDE\Extensions\k04kuuo3.ie0\packages\vs-mda\install" "C:\Program Files (x86)
\nodejs\" "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7
\IDE\Extensions\k04kuuo3.ie0\packages\vs-mda"" exited with code 8.
File %USERPROFILE%\AppData\Roaming\npm\node_modules\vs-mda-targets\Microsoft.MDA.targets
Line 108
Column 5
Project BlankCordovaApp1
Environment settings:
ADT_HOME %USERPROFILE%\AppData\Local\Android\android-sdk
ANT_HOME C:\apache-ant-1.9.3
GIT_HOME C:\Program Files (x86)\Git\cmd
JAVA_HOME C:\Program Files (x86)\Java\jdk1.7.0_55
PATH %JAVA_HOME%\bin;%ANT_HOME%\bin;%ADT_HOME%\platform-tools;%ADT_HOME%\tools;
C:\Program Files (x86)\nodejs\;C:\Program Files (x86)\Windows Kits\8.1\Windows
Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;
C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\
(contains no reference to "Platform")
Your kind help is very much appreciated, Thanks Ian
I just ran into this on one of my PCs and here's how I got it fixed:
Quit Visual Studio
Open the Android SDK manager by typing the Windows key and then "SDK manager", hit enter
Install Android Build Tools Rev 19 by checking the box next to it and clicking Install packages
Accept the license
Open Visual Studio and your project, then run it again
Jordan (Microsoft, Multi-Device Hybrid Apps tools team)
Finally the light bulb went on for me: The problem was the install batch files not being able to locate xcopy.exe and therefore the simple remedy was to just extend the path variable with
%SystemRoot%\system32;
The build now runs without further errors.
Thanks Jordan and Ian.
I ended up doing both.
I ran the Android SDK manager to install the Android Build Tools Rev 19 as well as some other updates.
I also added "%SystemRoot%\system32;" to the PATH environment variable.
Everything running as it should.

Resources