visual-studio - VS Enterprise .NET Build Extensions 版本的 System.Net.Http 覆盖预期的 4.3.3 nuget 版本

标签 visual-studio http nuget enterprise-library system.net

我目前使用的是 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/

相关文章:

android httprequest java.net.UnknownHostException

c# - 使用WebClient下载时出现操作超时错误

visual-studio - Package Restore 在 2.7 和 2.8 之间发生了什么变化?

C# 项目、正确的版本控制、公司等部署

c# - 如何在 Visual Studio 2008 中自动发布网站?

c# - 对枚举类型名称的编辑未反射(reflect)在 VS2015 *.settings 文件 C# 中

entity-framework - 尝试添加迁移 - 包管理器控制台中的异常 : "Cannot get an instance of EnvDTE.DTE"

c# - 为什么C#编译符号不建议缩进?

linux - cookie 是如何工作的

github - 如何正确地将 git push 与 nuget 集成?