kofifus
kofifus

Reputation: 19315

Forcing VS to use an assembly with a lower version

This is a general question but I will describe my specific scenario - My project is a .NET Core 3.0 SignalR Console application in VS19 (same with VS17)

After upgrading everything to Core 3.0 build now fails with:

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'

What I understand is that despite the nuget highest version of Microsoft.AspNetCore.Http.Connections.Common being 1.0.0.0, for some reason Microsoft.AspNetCore.SignalR.Client requires 3.0.0.0 which does not exist (yet).

How can I tell VS to use Microsoft.AspNetCore.Http.Connections.Common 1.0.0.0 instead ?

I tried in my csproj to add specific version to the reference:

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

But nothing changed. I also tried with <SpecificVersion>True</SpecificVersion>, same result :(

Any help ?

Upvotes: 0

Views: 79

Answers (1)

Simply Ged
Simply Ged

Reputation: 8672

Some of the .NET Core prerelease libraries aren't available on the main NuGet feed. You need to add the nightly/dev feed to your NuGet package sources and, hopefully, it should be available there.

The feeds are:

ASP.NET Core

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

.NET Core

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

To add the feed to Visual Studio

  1. In the Manage NuGet Packages window for your project click on the cog in the top right corner.
  2. In the new dialog click the red 'x' in the top right
  3. Paste the URL above in the "Source" tex box
  4. Give the feed a name (e.g. ASP.NET Core Dev)
  5. Click Update
  6. Ensure the feed is at the bottom of the list (so this is the last one used for packages)
  7. Click OK

Now you can change the Package Source in the NuGet window to either your new feed or "All" and click the 'include prerelease' to see the pre-release versions of the packages.

Upvotes: 1

Related Questions