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

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.).


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>