强制 VS 使用较低版本的程序集

Forcing VS to use an assembly with a lower version

这是一个一般性问题,但我将描述我的具体情况 - 我的项目是 VS19 中的 .NET Core 3.0 SignalR 控制台应用程序(与 VS17 相同)

将所有内容升级到 Core 3.0 后构建现在失败:

Error CS1705 Assembly 'Microsoft.AspNetCore.SignalR.Client' with identity
'Microsoft.AspNetCore.SignalR.Client, Version=3.0.0.0, Culture=neutral,
PublicKeyToken=adb9793829ddae60' uses 'Microsoft.AspNetCore.Http.Connections.Common, 
Version=3.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' which has a higher version 
than referenced assembly 'Microsoft.AspNetCore.Http.Connections.Common' with identity 
'Microsoft.AspNetCore.Http.Connections.Common, Version=1.1.0.0, Culture=neutral,
PublicKeyToken=adb9793829ddae60'

我的理解是,尽管 Microsoft.AspNetCore.Http.Connections.Common 的 nuget 最高版本是 1.0.0.0,但出于某种原因 Microsoft.AspNetCore.SignalR.Client 需要 3.0.0.0,它(目前)还不存在。

如何告诉 VS 使用 Microsoft.AspNetCore.Http.Connections.Common 1.0.0.0 代替?

我尝试在我的 csproj 中将特定版本添加到参考中:

<PackageReference Include="Microsoft.AspNetCore.Http.Connections.Common" Version="1.1.0">
  <SpecificVersion>False</SpecificVersion>
</PackageReference>

但没有任何改变。我也试过 <SpecificVersion>True</SpecificVersion>,同样的结果 :(

有帮助吗?

一些 .NET Core 预发布库在主 NuGet 提要上不可用。您需要将 nightly/dev 提要添加到您的 NuGet 包源中,希望它应该在那里可用。

提要是:

ASP.NET核心

https://dotnet.myget.org/gallery/aspnetcore-dev

.NET Core

https://dotnet.myget.org/F/dotnet-core/api/v3/index.json

将 Feed 添加到 Visual Studio

  1. 在项目的管理 NuGet 包 window 中,单击右上角的齿轮。
  2. 在新对话框中点击右上角的红色'x'
  3. 将上面的 URL 粘贴到 "Source" 文本框中
  4. 为提要命名(例如 ASP.NET Core Dev)
  5. 点击更新
  6. 确保提要位于列表的底部(因此这是用于包的最后一个)
  7. 点击确定

现在您可以将 NuGet window 中的包源更改为您的新提要或 "All",然后单击 'include prerelease' 查看包的预发布版本。