6
votes

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
what happens if you completely close VS, do dotnet restore on a command line and open the solution again? This package is implicitly referenced and the NuGet UI is explicitly supposed not to perform any updates for this package.Martin Ullrich
restore successful. After opening solution again I see one warning in error list: Detected package downgrade: Microsoft.NETCore.App from 1.1.2 to 1.1.1 .... Consolidation still doesn't workastef
It depends on the version of Visual Studio that you are using, but if you're using Visual Studio 2015, please share your project.json file(s). If you are using Visual Studio 2017 please share your *.csproj file(s). -- We are looking for the exact framework that you are targeting and making sure all your project point to the same (or compatible) one.Svek
@MichaelFreidgeim except it was asked earlierastef

3 Answers

12
votes

If you manually upgraded before, a Microsoft.NETCore.App package on some projects, they will contain an element like <PackageReference Update="Microsoft.NETCore.App" Version="1.1.1" />.

The reason is that the Microsoft.NET.Sdk SDK creates an implicit package reference.

Since the package is implicitly referenced, NuGet should not have done this in the first place and the current VS updates no longer allow to update implicitly referenced packages.

You can do two things here:

  1. Remove all PackageReference elements that change/set the version of Microsoft.NET.Sdk. This will then let the SDK version (included in MSBuild / dotnet cli) choose the version.
  2. 1 + In a <PropertyGroup> of your csproj files, set

     <RuntimeFrameworkVersion>1.1.2</RuntimeFrameworkVersion>
    

    This will set the version that the implicit reference of the SDK will use.

  3. 1 + In a <PropertyGroup> of your csproj files, set

    <DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
    

    And then install the desired version of Microsoft.NETCore.App manually

I recommend going with Option 1 since it doesn't require you to modify csproj files any more (e.g. when adding new projects, restructuring solutions etc.).

2
votes

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>
1
votes

As Martin said, I removed all the NETCore PackageReference from all projects, cleaned, opened Nuget Manager and installed the versions I neede after downloading and installing the latest sdk from

https://dotnet.microsoft.com/download/visual-studio-sdks?utm_source=getdotnetsdk&utm_medium=referral