我目前使用的是 Visual Studio 2017 企业版。我遇到的问题是,每次我将最新的 System.Net.Http nuget 包 (4.3.3) 安装到项目中时,System.Net.Http 引用似乎更喜欢指向 VS Enterprise 扩展版本系统.Net.Http:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net471\lib\System.Net.Http.ddl
我尝试了所有方法来强制它使用 nuget 版本,包括绑定(bind)重定向:
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.1.2" newVersion="4.1.1.2" />
</dependentAssembly>
并在 .csproj 文件中设置“HintPath”:
<Reference Include="System.Net.Http, Version=4.1.1.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Net.Http.4.3.3\lib\net46\System.Net.Http.dll</HintPath>
</Reference>
但它仍然只是快速返回到上述 VS Enterprise 扩展版本。我需要能够使用 System.Net.Http dll 的 nuget 版本,因为我有另一个依赖它的库 (Serilog)。
两个问题:(1)为什么会这样? (2) 如何强制忽略它的 VS Enterprise 版本?
最佳答案
这看起来像是在 .net Framework 4.6 中引用包的一些问题:
If you're building a .NET Framework 4.6.x app, you should just use standard references to System.Net.Http and not bring in any Nuget package for System.Net.Http.
您可以尝试将项目中的 .net framework 升级到最新版本。有关此问题的更多信息:System.Net.Http v4.2.0.0 being copied/loaded from MSBuild tooling
关于visual-studio - VS Enterprise .NET Build Extensions 版本的 System.Net.Http 覆盖预期的 4.3.3 nuget 版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50828081/