繁体   English   中英

将C ++项目添加到解决方案时出现CS1705错误

[英]CS1705 error while adding a C++ project to solution

嗨,谢谢你。 我正在使用TFS build 2013(团队服务,而不是前提条件)来构建我的解决方案。 在解决方案中创建新的C ++项目后,我无法成功构建。 我在构建机器上遇到的错误是:

    C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\CodeAnalysis\Microsoft.CodeAnalysis.targets
    (219): An error has occurred during compilation. error CS1705: Assembly 'Microsoft.Build.Utilities.Core,
    Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' uses 'Microsoft.Build.Framework,
    Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' which has a higher
    version than referenced assembly 'Microsoft.Build.Framework, Version=12.0.0.0, Culture=neutral,
    PublicKeyToken=b03f5f7f11d50a3a'

    C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\CodeAnalysis\Microsoft.CodeAnalysis.targets
    (219): The "SetEnvironmentVariable" task was not found. Check the following: 1.) The name of the task in the project file is the same as the name
    of the task class. 2.) The task class is "public" and implements the Microsoft.Build.Framework.ITask
    interface. 3.) The task is correctly declared with <UsingTask> in the project file, or
    in the *.tasks files located in the "C:\Program Files (x86)\MSBuild\14.0\bin\amd64" directory.

我对Internet上的错误CS1705感到迷惑不解,但我仍然不明白为什么会收到此错误-该项目是一个空项目,至今没有任何引用,也没有其他项目引用过它。

我的目标是在所有C#项目上使用.NET Framework 4.6.1,并在我的构建定义中添加以下msbuild参数:/tv:14.0 /p:VisualStudioVersion=14.0,因此它使用2015年版本的c#编译器。 此C ++项目的目标平台是VS 2015(v140),如下所示: C ++项目配置

不用说,当我从要构建的项目列表(配置管理器)中删除此项目时,该解决方案将成功构建。

任何帮助/线索将不胜感激!

问题是我想的以外的问题。 似乎它与CodeAnalysis和与之相关的一些环境变量有关。 在我的构建定义中,我禁用了CodeAnalysis,甚至在C ++项目属性中也将其禁用。 在注释掉构建计算机上此文件内“ SetCABuildNativeEnvironmentVariables”目标上的一些属性后:

"C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\CodeAnalysis\Microsoft.CodeAnalysis.targets"

问题消失了。

但是,这是一个令人讨厌的解决方法,因为我不完全了解实际情况。

还是非常感谢!

似乎还有点指向"Microsoft.Build.Framework, Version=12.0.0.0"

/tv:14.0命令参数无法按预期工作。 请参阅: BuildActivity忽略ToolsVersion

解决方法是,您需要自定义构建过程模板:

  1. 在Visual Studio中打开模板,然后找到“运行MSBuild for Project MSBuild”活动。
  2. 将ToolVersion设置为“ 14.0”。
  3. 将ToolPath设置为以MSBuild14为目标(默认情况下:“ C:\\ Program Files(x86)\\ MSBuild \\ 14.0 \\ Bin”)。
  4. 签入此构建过程模板,然后重新排队构建。

您还可以在TFS 2013 Building .NET 4.6 / C#6.0中引用Marson的答案

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM