【发布时间】:2012-05-02 02:30:27
【问题描述】:
安装 MSVS 11Beta 后,我遇到了 MSVS 10 的编译问题。现在,当我在 MSVS 10 中编译我的 C# 项目(在 MSVS 10 中创建的项目;目标框架:3.5)时,我收到错误MSB4216、MSB4028,并在输出窗口中显示以下文本:
1>Task "GenerateResource" skipped, due to false condition; ('%(EmbeddedResource.Type)' == 'Resx' and '%(EmbeddedResource.GenerateResource)' != 'false' and '$(GenerateResourceMSBuildRuntime)' != 'CLR2') was evaluated as ('Resx' == 'Resx' and '' != 'false' and 'CLR2' != 'CLR2').
1>Task "GenerateResource"
1> Launching task "GenerateResource" from assembly "Microsoft.Build.Tasks.v3.5, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" in an external task host with a runtime of "CLR2" and a process architecture of "x86".
1>C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(2199,5): error MSB4216: Could not run the "GenerateResource" task because we could not create or connect to a task host with runtime "CLR2" and architecture "x86". Please ensure that (1) the requested runtime and/or architecture are available on the machine, and (2) that the required executable "C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NetFX 4.0 Tools\MSBuildTaskHost.exe" exists.
1>C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(2217,7): error MSB4028: The "GenerateResource" task's outputs could not be retrieved from the "FilesWritten" parameter. Object does not match target type.
1>Done executing task "GenerateResource" -- FAILED.
如何解决这些错误?
编辑:
- 提到的文件“C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NetFX 4.0 Tools\MSBuildTaskHost.exe”存在。
- C++ 项目编译没有问题。
- 重新安装 VS10 并不能解决问题。
- 这是
GenerateResource任务,必须编译 resx 文件,但会产生异常:
<!-- But we can't use those parameters if we're targeting 3.5, since we're using the 3.5 task -->
<GenerateResource
Sources="@(EmbeddedResource)"
UseSourcePath="$(UseSourcePath)"
References="@(ReferencePath)"
AdditionalInputs="$(MSBuildAllProjects)"
NeverLockTypeAssemblies="$(GenerateResourceNeverLockTypeAssemblies)"
StateFile="$(IntermediateOutputPath)$(MSBuildProjectFile).GenerateResource.Cache"
StronglyTypedClassName="%(EmbeddedResource.StronglyTypedClassName)"
StronglyTypedFileName="%(EmbeddedResource.StronglyTypedFileName)"
StronglyTypedLanguage="%(EmbeddedResource.StronglyTypedLanguage)"
StronglyTypedNamespace="%(EmbeddedResource.StronglyTypedNamespace)"
StronglyTypedManifestPrefix="%(EmbeddedResource.StronglyTypedManifestPrefix)"
PublicClass="%(EmbeddedResource.PublicClass)"
OutputResources="@(EmbeddedResource->'$(IntermediateOutputPath)%(ManifestResourceName).resources')"
MSBuildRuntime="$(GenerateResourceMSBuildRuntime)"
MSBuildArchitecture="$(GenerateResourceMSBuildArchitecture)"
Condition="'%(EmbeddedResource.Type)' == 'Resx' and '%(EmbeddedResource.GenerateResource)' != 'false' and '$(GenerateResourceMSBuildRuntime)' == 'CLR2'">
- 我尝试了debug MSBuild 脚本 (
.csproj)。就在致命的GenerateResource任务之前,我检查了所有属性 和项目。没有关于“8.0A”的内容,只有关于“7.0A”的内容
【问题讨论】:
-
您是否根据错误检查了所需文件是否存在? “请确保 (1) 请求的运行时和/或体系结构在机器上可用,以及 (2) 所需的可执行文件 "C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NetFX 4.0 Tools\MSBuildTaskHost.exe”存在。”
-
@Chris - 是的,该文件存在,我可以在 procmon 日志中看到该应用程序“C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NetFX 4.0 Tools \MSBuildTaskHost.exe" 已启动并正在执行一些操作。
-
可能是路径问题。 VS11 可能设置了一个路径,该路径覆盖了您的构建脚本假定的路径,并且使用了错误版本的文件或 dll。检查你的路径。
-
@MystereMan - 谢谢。你的意思是VS11改变了我的
Microsoft.Common.targets? -
您是否尝试过简单地重新安装 VS10?
标签: c# .net visual-studio-2010 msbuild visual-studio-2012