MSBuild"GenerateFakes"错误MSB4127,MSB4060

编程入门 行业动态 更新时间:2024-10-09 09:12:26
本文介绍了MSBuild"GenerateFakes"错误MSB4127,MSB4060的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

使用Visual Studio 2013进行构建时,GenerateFakes成功执行,它使用到相同目标文件的相同路径.

When building using Visual Studio 2013 the GenerateFakes succeeds, it uses the same path to the same target file.

通过MSBuild 12.0(Visual Studio 2013附带的相同版本)进行构建时,出现以下两个错误.

When building via MSBuild 12.0 (Same version shipped with Visual Studio 2013) I get the following two errors.

错误#1

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Fakes\Microsoft.QualityTools.Testing.Fakes.targets(128,5): error MSB4127: The "GenerateFakes" task could not be instantiated from the assembly "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Fakes\Microsoft.QualityTools.Testing.Fakes.Tasks.dll". Please verify the task assembly has been built using the same version of the Microsoft.Build.Framework assembly as the one installed on your computer and that your host application is not missing a binding redirect for Microsoft.Build.Framework. Unable to cast object of type 'Microsoft.QualityTools.Testing.Fakes.GenerateFakes' to type 'Microsoft.Build.Framework.ITask'.

错误#2

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Fakes\Microsoft.QualityTools.Testing.Fakes.targets(128,5): error MSB4060: The "GenerateFakes" task has been declared or used incorrectly, or failed during construction. Check the spelling of the task name and the assembly name.

我可以在使用Visual Studio 2012的旧计算机上成功使用MSBuild 11.0进行构建.

I could successfully build using MSBuild 11.0 on an old machine which was using Visual Studio 2012.

该问题是否与某种缺少绑定重定向有关?

以下链接包含类似的错误,但适用于另一个框架: social.msdn.microsoft/forums/vstudio/en-US/2772a075- 4e2f-42af-9e7a-2228b794368e/msbuild崩溃并无法实例化消息任务

The following link contains a similar error but for another framework: social.msdn.microsoft/forums/vstudio/en-US/2772a075-4e2f-42af-9e7a-2228b794368e/msbuild-crashes-with-a-message-task-could-not-be-instantiated-exception

仅注意到删除所有项目中的FakeAssemblies文件夹可以解决此问题,但是一旦我在Visual Studio中再次构建,该错误就会再次出现.

推荐答案

要解决此问题,我必须在全局属性中将VisualStudioVersion设置为12.0.从命令行运行MSBuild.exe时,或使用MSBuild API时,都需要这样做.

To fix the issue i've had to set the VisualStudioVersion to 12.0 in the global properties. This needs to be done both when running MSBuild.exe from the command line, or when using the MSBuild API.

使用API​​:

我不得不手动引用可以在Program Files (x86)\MSBuild\12.0\Bin

I have had to manually reference the MSBuild 12.0 Dlls which can be found in Program Files (x86)\MSBuild\12.0\Bin

接下来,复制了MSBuild.exe.config中的程序集重定向并将其粘贴到我的app.config中.

Next copied the assembly redirects from MSBuild.exe.config and pasted them into my app.config.

<runtime> <DisableFXClosureWalk enabled="true" /> <generatePublisherEvidence enabled="false" /> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="Microsoft.Build.Framework" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/> <bindingRedirect oldVersion="0.0.0.0-99.9.9.9" newVersion="12.0.0.0"/> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="Microsoft.Build.Engine" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/> <bindingRedirect oldVersion="0.0.0.0-99.9.9.9" newVersion="12.0.0.0"/> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="Microsoft.Build" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/> <bindingRedirect oldVersion="0.0.0.0-99.9.9.9" newVersion="12.0.0.0"/> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="Microsoft.CompactFramework.Build.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/> <bindingRedirect oldVersion="0.0.0.0-99.9.9.9" newVersion="12.0.0.0"/> </dependentAssembly> </assemblyBinding> </runtime>

更多推荐

MSBuild"GenerateFakes"错误MSB4127,MSB4060

本文发布于:2023-11-28 21:35:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1644028.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   quot   MSBuild   GenerateFakes

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!