【问题标题】:VS Enterprise .NET Build Extensions version of System.Net.Http overrides intended 4.3.3 nuget versionVS Enterprise .NET Build Extensions 版本的 System.Net.Http 覆盖预期的 4.3.3 nuget 版本
【发布时间】:2018-06-13 01:53:26
【问题描述】:

我目前使用的是 Visual Studio 2017 企业版。我遇到的问题是,每次我将最新的 System.Net.Http nuget 包(4.3.3)安装到项目中时,System.Net.Http 参考似乎更喜欢指向 VS Enterprise 扩展版本System.Net.Http:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net471\lib\System.Net.Http.ddl

我尝试了一切来强制它使用 nuget 版本,包括绑定重定向:

  <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版本?

【问题讨论】:

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


    【解决方案1】:

    这看起来像是在 .net 框架 4.6 中引用包的一些问题:

    如果您正在构建 .NET Framework 4.6.x 应用程序,您应该只使用 对 System.Net.Http 的标准引用,不引入任何 Nuget System.Net.Http 的包。

    您可以尝试将项目中的 .net 框架升级到最新版本。有关此问题的更多信息:System.Net.Http v4.2.0.0 being copied/loaded from MSBuild tooling

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-03-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-07
      • 1970-01-01
      • 2013-12-06
      • 2017-02-24
      相关资源
      最近更新 更多