[英]Referenced DLL From Project Targeting .Net Framework 4.6 is no longer appearing in bin When Project Upgraded to .Net Framework 4.7.2
I have two projects, [Service] and [Web].我有两个项目,[Service] 和 [Web]。 Both were originally built targeting .Net Framework 4.6.
两者最初都是针对 .Net Framework 4.6 构建的。 [Web] references [Service], and uses some of the DLLs (specially,
System.Runtime.InteropServices.RuntimeInformation.dll
and System.Net.Http.dll
) that [Service] has installed via NuGet packages. [Web] 引用 [Service],并使用 [Service] 通过 NuGet 包安装的一些 DLL(特别是
System.Runtime.InteropServices.RuntimeInformation.dll
和System.Net.Http.dll
)。
[Web] needs to upgrade to target .Net Framework 4.7.2. [Web] 需要升级到目标 .Net Framework 4.7.2。 This has been done, however, those two DLLs from [Service] no longer appear in the
bin/
directory of [Web].这已经完成了,但是,[Service] 中的那两个 DLL 不再出现在 [Web] 的
bin/
目录中。
I am using Visual Studio 2017 Enterprise.我正在使用 Visual Studio 2017 企业版。
System.Runtime.InteropServices.RuntimeInformation.dll
comes from Microsoft.AspNetCore.Mvc
System.Runtime.InteropServices.RuntimeInformation.dll
来自Microsoft.AspNetCore.Mvc
System.Net.Http
comes from its own Nuget package System.Net.Http
来自它自己的 Nuget 包EDIT:编辑:
I have since found this buried deep into the detailed log of the build:从那以后,我发现这深深地隐藏在构建的详细日志中:
Unified Dependency "System.Runtime.InteropServices.RuntimeInformation, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
29> Using this version instead of original version "4.0.1.0" in "C:\Users\baker\.nuget\packages\microsoft.aspnetcore.hosting\1.1.2\lib\net451\Microsoft.AspNetCore.Hosting.dll" because AutoUnify is 'true'.
29> Using this version instead of original version "4.0.1.0" in "C:\Users\baker\.nuget\packages\microsoft.aspnetcore.server.kestrel\1.1.2\lib\net451\Microsoft.AspNetCore.Server.Kestrel.dll" because AutoUnify is 'true'.
29> Using this version instead of original version "4.0.1.0" in "C:\Users\baker\.nuget\packages\microsoft.extensions.logging.console\1.1.2\lib\net451\Microsoft.Extensions.Logging.Console.dll" because AutoUnify is 'true'.
29> Resolved file path is "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\Facades\System.Runtime.InteropServices.RuntimeInformation.dll".
29> Reference found at search path location "{TargetFrameworkDirectory}".
29> For SearchPath "C:\Users\baker\.nuget\packages\microsoft.aspnetcore.hosting\1.1.2\lib\net451".
29> Considered "C:\Users\baker\.nuget\packages\microsoft.aspnetcore.hosting\1.1.2\lib\net451\System.Runtime.InteropServices.RuntimeInformation.winmd", but it didn't exist.
29> Considered "C:\Users\baker\.nuget\packages\microsoft.aspnetcore.hosting\1.1.2\lib\net451\System.Runtime.InteropServices.RuntimeInformation.dll", but it didn't exist.
29> Considered "C:\Users\baker\.nuget\packages\microsoft.aspnetcore.hosting\1.1.2\lib\net451\System.Runtime.InteropServices.RuntimeInformation.exe", but it didn't exist.
29> For SearchPath "{CandidateAssemblyFiles}".
29> Considered "net472Dlls\System.Net.Http.dll",
29> but its name "System.Net.Http"
29> didn't match the expected name "System.Runtime.InteropServices.RuntimeInformation, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
29> Considered "net472Dlls\System.Runtime.InteropServices.RuntimeInformation.dll",
29> but its name "System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
29> didn't match the expected name "System.Runtime.InteropServices.RuntimeInformation, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
29> For SearchPath "{TargetFrameworkDirectory}".
29> Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Runtime.InteropServices.RuntimeInformation.winmd", but it didn't exist.
29> Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Runtime.InteropServices.RuntimeInformation.dll", but it didn't exist.
29> Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Runtime.InteropServices.RuntimeInformation.exe", but it didn't exist.
29> Considered "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\Facades\System.Runtime.InteropServices.RuntimeInformation.winmd", but it didn't exist.
29> Required by "C:\Users\baker\.nuget\packages\microsoft.aspnetcore.hosting\1.1.2\lib\net451\Microsoft.AspNetCore.Hosting.dll".
29> Required by "C:\Users\baker\.nuget\packages\microsoft.aspnetcore.server.kestrel\1.1.2\lib\net451\Microsoft.AspNetCore.Server.Kestrel.dll".
29> Required by "C:\Users\baker\.nuget\packages\microsoft.aspnetcore.server.kestrel.https\1.1.2\lib\net451\Microsoft.AspNetCore.Server.Kestrel.Https.dll".
29> Required by "C:\Users\baker\.nuget\packages\microsoft.extensions.logging.console\1.1.2\lib\net451\Microsoft.Extensions.Logging.Console.dll".
29> This reference is not "CopyLocal" because it conflicted with another reference with the same name and lost the conflict.
29> The ImageRuntimeVersion for this reference is "v4.0.30319".
Sounds like this issue .听起来像这个问题。
From the link:从链接:
The workaround is to add an extra package reference to your project file and exclude all of its assets in order to make sure that the package implementation is never preferred.解决方法是向您的项目文件添加一个额外的包引用并排除其所有资产,以确保永远不会首选包实现。 This ensures that the platform version wins and is not removed by the NuGet targets.
这可确保平台版本获胜并且不会被 NuGet 目标删除。 Here is an example of how to do this for the System.Net.Http.dll case:
以下是如何针对 System.Net.Http.dll 情况执行此操作的示例:
<ItemGroup>
<PackageReference Include="System.Net.Http" Version="4.3.3">
<ExcludeAssets>All</ExcludeAssets>
</PackageReference>
</ItemGroup>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.