3

我有许多针对.Net 4.6和一个本地C++项目(无CLR)的C#项目的解决方案。在VS2015中使用该解决方案后,我现在在尝试打开VS2013中的解决方案时出现错误,一半项目未能加载。对于VS2013中的.Net 4.6的某些项目,项目加载失败

本地C++项目和一些C#项目给出错误:

error : A numeric comparison was attempted on "$(TargetPlatformVersion)" that evaluates to "10.0.10069.0" instead of a number, in condition "'$(TargetPlatformVersion)' > '8.0'". C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets

我不知道为什么有些项目正确加载和其他人不这样做,但是,它看起来像所有的C#项目哪些参考NuGet包失败。

有没有办法解决这些错误,并允许在VS2013和VS2015中打开解决方案和项目?

回答

2

在尝试对项目文件进行各种更改后,我发现从本机C++项目中删除以下行,然后允许解决方案中的所有项目正确加载。

<TargetPlatformVersion>10.0.10069.0</TargetPlatformVersion> 

然而,加载后我随后发现,我无法建立,因为错误的本地项目:

error MSB8020: The build tools for v140 (Platform Toolset = 'v140') cannot be found.

即使vcxproj指定ToolsVersion="14.0"看来,Visual Studio的2013年将使用12.0对于C++项目。在项目的属性Platform toolsetv140 (not installed)。将其更改为Visual Studio 2013 (v120)将允许在VS2013和VS2015中构建项目,但显然使用较旧的12.0工具而不是14.0。相反,我添加了以下行到我的项目文件:

<PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0'">v120</PlatformToolset> 
<PlatformToolset Condition="'$(VisualStudioVersion)' >= '14.0'">v140</PlatformToolset> 

现在VS2013将使用v120Platform toolset和VS2105(或更高版本)将使用v140

使用VS 2015构建项目文件后,可能会添加TargetPlatformVersion和/或WindowsTargetPlatformVersion行。如果值为10.0.10240.0或另一个Windows 10版本,则该项目不会在VS 2013中加载,因为它不喜欢非十进制值。 即使你可以用VS2013面向.NET 4.6它不会:这可以通过将值更改为8.1,告诉Visual Studio中使用Windows工具包的Windows 8.1,而比Windows 10

注固定了解C#6,如果您尝试使用任何新的语言功能,将会出现错误。同样,针对C++项目定位v120将阻止您使用VS2015中支持的更新语言功能。

+1

此答案主要针对C++。我遇到了同样的C#错误消息,其中之前不成功的更新可能会损坏MSBuild 12.修复程序是修复Visual Studio 2013 Update 5. –

+0

我可以删除WindowsTargetPlatformVersion吗? – lindexi