我们正在使用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 SDKsWindowsv8.1AbinNETFX 4.5.1 ToolsAL.exe /culture:de /keyfile:....MyApp.snk /out:objx64ReleasedeMyApp.Hardware.Softing.resources.dll /platform:x64 /template:objx64ReleaseMyApp.Hardware.Softing.dll /embed:objx64ReleaseMyApp.Hardware.Softing.Properties.Resources.de.resources
[17:01:18]ALINK warning AL1073: Referenced assembly 'mscorlib.dll' targets a different processor
这是一个解决方法:
可以通过使用与您试图构建的平台(或位)匹配的AL.EXE来避免此问题。也就是说,当您构建x64时,您将看到它试图在类似于
的路径下使用AL.EXE。 C:Program Files (x86)Microsoft SDKsWindowsv10.0AbinNETFX 4.6 Tools
如果你能让它使用x64版本的AL.exe,这个问题就会消失。也就是说,在类似于
的路径下使用AL.EXE: C:Program Files (x86)Microsoft SDKsWindowsv10.0AbinNETFX 4.6 Toolsx64
Msbuild通过使用它的TargetFrameworkSDKToolsDirectory
找到这个路径。因此,假设在构建x86时该目录是正确的目录,下面的解决方法实际上是在构建x64时将x64子目录附加到路径上,并保持路径不变:
创建MsBuildAL1073WarningWorkaround。目标文件(名称无关紧要)并将其添加到项目中。它有以下内容:
<?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文件,在文件末尾导入这个文件(在这里你会看到注释说"to modify your build process…")。:
<Import Project="MsBuildAL1073WarningWorkaround.targets" /> <!-- To modify your build process... -->
这些警告显示在包含本地化卫星程序集(的项目中。Resx文件)中的解决方案。
这是微软方面的错误,截至2017年8月,微软仍然没有修复它。
以下是微软反馈页面的引用:
它是由。net框架二进制文件中的逻辑错误引起的alink.dll。但考虑到这个问题的影响有限,而且事实是这个工具对我们的服务有很高的要求解决此问题的更改。
问候,
Ed Maurer开发主管,VB &c#编译器
可以忽略此警告。因为。net将在64位机器的运行时加载正确的64位程序集。对于这个问题,微软仍然可以给出一个可靠的答案。警告是不必要的浪费时间。
我们遇到了同样的问题,最终采用了Matt Smith的解决方案(https://stackoverflow.com/a/41945190/3506760),并进行了一次修改,使其正常工作。
由于MsBuild (https://stackoverflow.com/a/1367309/3506760)中的功能/错误,我们需要修改步骤1中描述的目标文件。
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="MsBuildAL1073WarningWorkaround" BeforeTargets="BeforeBuild" >
<PropertyGroup Condition="'$(Platform)' == 'x64'">
<TargetFrameworkSDKToolsDirectory>$(TargetFrameworkSDKToolsDirectory)$(Platform)</TargetFrameworkSDKToolsDirectory>
</PropertyGroup>
</Target>
</Project>
虽然@jero2rome引用的错误被关闭为不会修复,但VS2015 RC w/.NET 4.6不再发出此警告:
从VS2013/。. NET 4.5.1,我也会看到同样的问题:
GenerateSatelliteAssemblies:
C:Program Files (x86)Microsoft SDKsWindowsv8.1AbinNETFX 4.5.1 ToolsAL.exe /culture:zh-CHT /out:objx64Debugzh-CHTMyComponent.resources.dll /platform:x64 /template:objx64DebugMyComponent.dll /embed:objx64DebugMyComponent.Resources.string.zh-CHT.resources
ALINK : warning AL1073: Referenced assembly 'mscorlib.dll' targets a different processor [c:svnprojectMyComponent.csproj]
With VS2015 RC/。. NET 4.6,不发出警告:
GenerateSatelliteAssemblies:
C:Program Files (x86)Microsoft SDKsWindowsv10.0AbinNETFX 4.6 Toolsx64AL.exe /culture:zh-CHT /out:objx64Debugzh-CHTMyComponent.resources.dll /platform:x64 /template:objx64DebugMyComponent.dll /embed:objx64DebugMyComponent.Resources.string.zh-CHT.resources
对Matt的回答做一些补充(我没有足够的声誉来添加评论):我相信
文件末尾
是在之后:
<Import Project="$(MSBuildToolsPath)Microsoft.CSharp.targets" />
我已经测试过了,如果上面的行在$TargetFrameworkSDKToolsDirectory的(重新)定义之前,那么AL1073警告消失了。
我的解决方案是:
<PropertyGroup>
<CreateSatelliteAssembliesDependsOn>
FixWarningAL1073;
$(CreateSatelliteAssembliesDependsOn);
</CreateSatelliteAssembliesDependsOn>
</PropertyGroup>
<Target Name="FixWarningAL1073">
<PropertyGroup>
<TargetFrameworkSDKToolsDirectory Condition=" '$(PlatformTarget)' == 'x64'">$(TargetFrameworkSDKToolsDirectory)$(PlatformTarget)</TargetFrameworkSDKToolsDirectory>
</PropertyGroup>
</Target>
将这些行添加到.csproj的末尾。
在我的情况下,从Properties/AssemblyInfo.cs
删除所有属性或删除整个文件修复警告,但这可能不适合大多数库的解决方案。Net461, sdk风格项目,<GenerateAssemblyInfo>
设置为false
要忽略该警告,您可以为所有OS_x86_x64安装。net Framework 4.5.2 developer pack,它与VS2013兼容。http://www.microsoft.com/en-us/download/details.aspx?id=42637