Why I can't consolidate projects sdk versions in Visual Studio?

Viewed 2052

First of all, I'm getting this build error, but only on some machines:

Error CS1705 Assembly '***' with identity '***, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' uses 'System.Net.Http, Version=4.1.1.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' which has a higher version than referenced assembly 'System.Net.Http' with identity 'System.Net.Http, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' *** C:\***\CSC 1 Active

I guess, it's somehow connected with SDK versions. From what I can see in Properties window, on some projects I have Microsoft.NETCore.App 1.1.1 while others have Microsoft.NETCore.App 1.1.2.

After package update, build succeeds (but why I am forced to update all packages?).

But still, sdk versions differ. And now I'm trying to use this consolidation feature of Visual Studio:

enter image description here

which says in a tooltip:

Following versions are unavaible due to additional constraints in the project or packages.config

How to upgrade all projects to newer SDK? And how to be sure not to break build on other machines in future?

3 Answers

Had the same problem in a ASP.NET Core 2.0 project - this worked for me:

Edit your 'myproject.csproj' file and add/update with the following:

  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
    <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
    <TargetLatestRuntimePatch>true</TargetLatestRuntimePatch> // add this line.
  </PropertyGroup>
Related