I've started getting the following error when attempting to run MSBuild via batch file on my machine.
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\AppxPackage\Microsoft.AppXPackage.Targets(283,22): error MSB4086: A numeric comparison was attempted on "10.0.11000.0" that evaluates to "10.0.11000.0" instead of a number, in condition "'$(TargetPlatformVersion)' >= '10.0.11000.0'". [MyProject.csproj]
This happens on several different projects within the solution.
I'm currently running VS2015 (Update 3). I updated from Update 2 on Friday. So it's possible that this could be related.
Based on various posts online (such as this one) it appears to have been (at some point in the past at least) caused by Resharper. However, I have updated Resharper to the latest version, and run a repair on the install, to no avail. I've even attempted to suspend it within Visual Studio itself.
I've also attempted to repair the VS215 installation itself. But am still getting the error.
How do I solve this error?
Update
So When I run this batch file, it's running using VisualStudioVersion=12.0
. This appears to be part of the issue. When I repoint it at 12.0
the build runs fine.
Checking into the targets file thats throwing the exception, you can see this on line 283:
<PropertyGroup>
<SdkIsRS1OrLater>False</SdkIsRS1OrLater>
<SdkIsRS1OrLater
Condition="'$(TargetPlatformVersion)' >= '10.0.11000.0'">True</SdkIsRS1OrLater>
</PropertyGroup>
So I'm not entirely sure why this is the case, but it appears to be an issue in the targets file from MS?
To run MSBuild at a command prompt, pass a project file to MSBuild.exe, together with the appropriate command-line options. Command-line options let you set properties, execute specific targets, and set other options that control the build process.
To enable msbuild in Command Prompt, you simply have to add the directory of the msbuild.exe install on your machine to the PATH environment variable. You can access the environment variables by: Right clicking on Computer. Click Properties.
To install MSBuild on a system that doesn't have Visual Studio, go to Build Tools for Visual Studio 2019, or install the . NET SDK. If you have Visual Studio, then you already have MSBuild installed. With Visual Studio 2022, it's installed under the Visual Studio installation folder.
To build a specific target of a specific project in a solution. At the command line, type MSBuild.exe <SolutionName>. sln , where <SolutionName> corresponds to the file name of the solution that contains the target that you want to execute.
Try setting the path and environment variables using the batch file shipped with VS2015 rather than setting the msbuild path and 'VisualStudioVersion' manually, to do this add the following to your batch file:
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"
I'm not sure what the root cause is, I suspect a mismatch of MSBuild and target file versions.
See https://msdn.microsoft.com/en-us/library/f2ccy3wt.aspx for more info on the batch file above.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With