- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 VS2019 和 .NET CORE 2.2 我收到警告 AL1073
ALINK 警告 AL1073:引用的程序集“mscorlib.dll”针对不同的处理器
我知道这与问题很接近:ALINK : warning AL1073: Referenced assembly 'mscorlib.dll' targets a different processor
但是:
我使用的是 .NET CORE 2.2,而不是 4.x
那里提出的解决方案不适用于.NET core
特别是尝试添加:
<PropertyGroup>
<TargetFrameworkSDKToolsDirectory Condition=" '$(PlatformTarget)' == 'x64'">$(TargetFrameworkSDKToolsDirectory)\$(PlatformTarget)\
</TargetFrameworkSDKToolsDirectory>
</PropertyGroup>
再次发出警告
Warning MSB3084 Task attempted to find "al.exe" in two locations. 1) Under the "\x64\" processor specific directory which is generated based on SdkToolsPath 2) The x86 specific directory under "\x64\" which is specified by the SDKToolsPath property. You may be able to solve the problem by doing one of the following: 1) Set the "SDKToolsPath" property to the location of the Microsoft Windows SDK. C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets
真的很奇怪,因为根据警告,位置是相同的!
此外:我很乐意在build设置中抑制警告,因为我的所有单元测试都通过了,但将 1073 添加到列表中对仍然出现的 AL1073 警告没有影响。
或者,警告建议:将“SDKToolsPath”属性设置为 Microsoft Windows SDK 的位置,我该怎么做?
更新回答评论:这很难通过简单的设置来重现。该项目特别引用了几个 Github 项目 (fo-dicom)。 fo-dicom 库使用为 32 和 64 平台构建的成像库。我确实尝试过设置为 64 位,但没有帮助。我看到其他人在 VS 社区提出了抑制警告似乎有问题的错误:https://developercommunity.visualstudio.com/content/problem/224196/suppress-warnings-from-project-settings-build-does.html 。该问题已关闭,没有后续行动,MSFT 也表示 AL 1073 不会得到修复,但我想禁用!使用持续集成时不能有警告...
我现在正在尝试重新编译 .NET CORE 3.0 中的所有内容,如果有效的话将提供更新。
更新:在 .NET CORE 3.0 中重新编译后,问题仍然存在。
我还发现了此问题的另一个原因(在其他 SO 文章中提到过,但对于 .NET 4.x。事实上,我看到资源文件也出现了该问题,但是对于 .NET Core,我们没有看到“生成Satellite Assemblies”消息,因此很难将编译器警告与资源文件的生成联系起来。
为了解决这个问题,我将 al.exe 文件从 C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\x64 复制到我的解决方案 Tools64 中,并添加了以下是我的 .csproj
<PropertyGroup>
<TargetFrameworkSDKToolsDirectory>..\Tools64</TargetFrameworkSDKToolsDirectory>
</PropertyGroup>
将 SDKToolsDirectory 直接设置到原始位置不起作用。在我的情况下,我们使用 DevOps 构建服务器进行持续集成(路径可能不同),因此不会额外使用绝对路径。将 al.exe 工具复制到本地似乎是一个可以接受的解决方案。
最佳答案
旧的解决方法仍然有效,但必须在 GenerateSatelliteAssemblies
目标之前完成。当它作为 PropertyGroup
添加到项目文件中时,它将被解释得太晚,从而导致两个位置警告。
如Marcel Veldhuizen所示,可以通过添加以下目标来使其工作:
<Target Name="FixAL1703Warning" BeforeTargets="GenerateSatelliteAssemblies" Condition="'$(PlatformTarget)' == 'x64'">
<Message Text="Adjusting SDK tools directory to use x64 version of AL.EXE">
<PropertyGroup>
<TargetFrameworkSDKToolsDirectory>$(TargetFrameworkSDKToolsDirectory)$(PlatformTarget)\</TargetFrameworkSDKToolsDirectory>
</PropertyGroup>
</Target>
注意:目前有一个 open issue在 GitHub 上的 msbuild 存储库中了解此内容。
关于c# - .NET Core ALINK : warning AL1073: Referenced assembly 'mscorlib.dll' targets a different processor,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58555465/
我是一名优秀的程序员,十分优秀!