Asp.net-core – Netcore 2.1.1 release leads to app failing to run

asp.net-core

It seems there is suddenly something out of sync with asp.net core packages.

It looks like Microsoft.AspNetCore.App 2.1.1 was released 16 hours ago on nuget.org but only 158 downloads, and apparently I'm one of the downloaders.

My .csproj file is like this:

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <ProjectReference Include="..\cloudscribe.Web.Navigation\cloudscribe.Web.Navigation.csproj" />
    <ProjectReference Include="..\cloudscribe.Web.SiteMap\cloudscribe.Web.SiteMap.csproj" />
    <ProjectReference Include="..\cloudscribe.Web.SiteMap.FromNavigation\cloudscribe.Web.SiteMap.FromNavigation.csproj" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.*" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.1.*" />
  </ItemGroup>
</Project>

It builds but when I try to run it I get:

It was not possible to find any compatible framework version
The specified framework 'Microsoft.AspNetCore.App', version '2.1.1' was not found.
– Check application dependencies and target a framework version installed at:
C:\Program Files\dotnet\
– Installing .NET Core prerequisites might help resolve this problem:
http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409
– The .NET Core framework and SDK can be installed from:
https://aka.ms/dotnet-download
– The following versions are installed:
2.1.0 at [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]

If I change my version for Microsoft.AspNetCore.App to 2.1.0 and do dotnet restore I get this:

C:_c\cloudscribe.Web.Navigation\src\NavigationDemo.Web\NavigationDemo.Web.csproj : error NU1107: Version conflict detected for Microsoft.AspNetCore.Antiforgery. Reference the package directly from the project to resolve this issue.
C:_c\cloudscribe.Web.Navigation\src\NavigationDemo.Web\NavigationDemo.Web.csproj : error NU1107: NavigationDemo.Web -> cloudscribe.Web.Navigation -> Microsoft.AspNetCore.Mvc.Razor 2.1.1 -> Microsoft.AspNetCore.Mvc.ViewFeatures 2.1.1 -> Microsoft.AspNetCore.Antiforgery (>= 2.1.1)
C:_c\cloudscribe.Web.Navigation\src\NavigationDemo.Web\NavigationDemo.Web.csproj : error NU1107: NavigationDemo.Web -> Microsoft.AspNetCore.App 2.1.0 -> Microsoft.AspNetCore.Antiforgery (= 2.1.0).
Restore failed in 3.54 sec for C:_c\cloudscribe.Web.Navigation\src\NavigationDemo.Web\NavigationDemo.Web.csproj.

I suppose that is partly due to the other projects in my solution with dependencies like this:

<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.1.*" />
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="2.1.*" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="2.1.*" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="2.1.*" />
<PackageReference Include="Microsoft.Extensions.Options" Version="2.1.*" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.*" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.1.*" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor" Version="2.1.*" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.1.*" />

There does not seem to be an updated sdk for 2.1.1 but the availability of Microsoft.AspNetCore.App 2.1.1 on GitHub seems to be breaking things for me.

Best Answer

Your problem is this line of your csproj:

<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.*" />

The * is saying to pick the latest 2.1 version of that NuGet package. For many packages, this would be perfectly fine. However, v2.1.1 of that package requires a matching v2.1.1 SDK to also be installed. As of right now, it is not available (it's currently blocked).

However, if you read the Migrate from ASP.NET Core 2.0 to 2.1 docs, you will see this:

Replace the version specified "Microsoft.AspNetCore.All" package reference with the versionless "Microsoft.AspNetCore.App" package reference.

The version is now inferred by the version of the SDK you are targeting. This means your csproj should now contain this:

<PackageReference Include="Microsoft.AspNetCore.App" />
Related Topic