我们正在使用 VS2013 和 .Net 4.5.1(最近迁移,但此错误来自 .Net 4.0)。只有在平台目标 x64 中编译项目时才会出现此错误。这真的是一个会在运行时中断的错误吗?为什么 MSBUILD 不能正确解析这个 mrcorlib.dll?这仅发生在 VS2010 中创建的项目中,而不会发生在新创建的项目中。我在这里错过了什么。我所有的第三方程序集都是 x64 位的。
在 TeamCity 构建服务器中,出现以下错误:
GenerateSatelliteAssemblies
[17:01:18]AL
[17:01:18]C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\AL.exe /culture:de /keyfile:..\..\MyApp.snk /out:obj\x64\Release\de\MyApp.Hardware.Softing.resources.dll /platform:x64 /template:obj\x64\Release\MyApp.Hardware.Softing.dll /embed:obj\x64\Release\MyApp.Hardware.Softing.Properties.Resources.de.resources
[17:01:18]ALINK warning AL1073: Referenced assembly 'mscorlib.dll' targets a different processor
最佳答案
解决办法:
可以通过使用与您尝试构建的平台(或位数)相匹配的 AL.EXE 来避免该问题。也就是说,当您构建 x64 时,您会看到它试图在类似于
的路径上使用 AL.EXEC:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6 工具
如果您可以让它使用 x64 版本的 AL.exe,问题就会消失。也就是说,在类似于以下的路径中使用 AL.EXE:
C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6 Tools\x64
Msbuild 通过使用其 TargetFrameworkSDKToolsDirectory
找到此路径。因此,假设在构建 x86 时该目录是正确的目录,下面的解决方法实质上是在构建 x64 时将 x64 子目录附加到路径上,否则保持原样:
创建 MsBuildAL1073WarningWorkaround.targets 文件(名称无关紧要)并将其添加到项目中。它具有以下内容:
<?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <TargetFrameworkSDKToolsDirectory Condition=" '$(PlatformTarget)' == 'x64'">$(TargetFrameworkSDKToolsDirectory)$(PlatformTarget)\</TargetFrameworkSDKToolsDirectory> </PropertyGroup> </Project>
编辑 .csproj 文件以在文件末尾附近导入此文件(您会在此处看到“要修改构建过程...”的注释):
<Import Project="MsBuildAL1073WarningWorkaround.targets" /> <!-- To modify your build process... -->
关于c# - 链接 : warning AL1073: Referenced assembly 'mscorlib.dll' targets a different processor,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25365616/