gpt4 book ai didi

.net - 引用和平台之间的 Visual Studio 冲突

转载 作者:行者123 更新时间:2023-12-04 15:06:22 28 4
gpt4 key购买 nike

由于我为 C# ASP.Net 项目将目标框架升级到 4.6.1,因此在构建过程中会收到很多冲突警告。 50 多条消息,例如:

Consider app.config remapping of assembly "System.Runtime.InteropServices.RuntimeInformation, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" from Version "0.0.0.0" [] to Version "4.0.2.0" [C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.Runtime.InteropServices.RuntimeInformation.dll] to solve conflict and get rid of warning.



它们都与 .NET 系统库有关。我当然可以重新映射所有引用,但不知何故我认为这不是正确的解决方案。如果我使用输出“详细”重建,我会得到更多信息:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\Microsoft.NET.Build.Extensions.ConflictResolution.targets(33,5): message NETSDK1041: Encountered conflict between 'Reference:System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL' and 'Reference:System.Runtime.InteropServices.RuntimeInformation'. NETSDK1033: Choosing 'Reference:System.Runtime.InteropServices.RuntimeInformation' because AssemblyVersion '4.0.2.0' is greater than '4.0.1.0'.



不知何故,文件夹 C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.6.1 和 C:\Program Files (x86)\Microsoft Visual Studio 中的 .NET 框架之间似乎存在版本冲突\2017\Professional\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib。

我不知道如何确保它使用来自同一个地方的引用。任何人都可以帮忙吗?

最佳答案

Visual studio conflicts between Reference and Platform



似乎是因为:

This is due to the injected support for NETStandard 2.0. We inject new assemblies into NET 4.6.1 and later desktop projects in order to add support for netstandard2.0. We do this in targets now instead of packages because its no longer a requirement to reference a package to build a netstandard library. This injection happens whenever we see a netstandard1.5 or greater library referenced (see dotnet/sdk#1386).



要解决此问题,您可以将绑定(bind)重定向添加到这些引用。

查看 System.Net.Http v4.2.0.0 being copied/loaded from MSBuild tooling了解更多详情。

希望这可以帮助。

关于.net - 引用和平台之间的 Visual Studio 冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52859229/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com