19
votes

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.

7
for the moment I can solve the problem by pinning all my packaged deps to 2.1.0 and close solution and delete the bin and obj folders. Then after re-opening my solution it builds and runs. As @khellang mentioned on gitter, maybe the 2.1.1 release is still in progress and not all ready yet.Joe Audette
Nuget usually takes some time until the cache is updated and a new verision of a specific package is visible on Nuget, that may be causing the issue. What may help is to install the latest SDK which should contain the latest ASP.NET Core installed in the local package cache (which is then located in C:\Program Files\dotnet\shared\Microsoft.NETCore.App and C:\Program Files\dotnet\sdk\NuGetFallbackFolder respectively and used as fallback by nuget)Tseng
@Tseng I think the problem may be because they haven't yet shipped a new sdk since the 2.1.0 release. The downloads don't show a new sdk version yet.Joe Audette
It is failing because you don;t have a matching SDK installed. Unfortunately Microsoft release the Nuget packages before the SDK installer so you either have to target a specific framework version or be patient and wait for the SDK.DavidG
Probably you need to wait until the .NET Core SDK 2.1.1 is available which u can find [here](microsoft.com/net/download/windows ). If u can't wait, check out the early access.SiberaIndustries

7 Answers

7
votes

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" />
7
votes

The 2.1.1 (preview) SDK is available on their GitHub.

You can download directly here:

https://dotnetfeed.blob.core.windows.net/orchestrated-release-2-1/20180605-09/final/assets/Sdk/2.1.301-preview-008906/dotnet-sdk-2.1.301-win-x64.exe

See:

https://github.com/dotnet/versions/tree/7a833dddfddc27f2074b755b94234a25b9757637/build-info/dotnet/product/cli/release/2.1

We are still waiting on the official SDK...

Edit:

If you are having trouble building, add the following to your .csproj

<PropertyGroup>     
  <TargetLatestAspNetCoreRuntimePatch>true</TargetLatestAspNetCoreRuntimePatch>
</PropertyGroup>

Update:

Official 2.1.1 SDK now released: https://www.microsoft.com/net/download/thank-you/dotnet-sdk-2.1.301-windows-x64-installer

1
votes

In addition to other suggestions, I needed to up the Microsoft.NetCore.App to 2.1.1. Since I couldn't do it via the UI, adding the following to the .csproj worked.

<PackageReference Include="Microsoft.NetCore.App" Version="2.1.1" />
0
votes

I had the same issue. Another option is, in NuGet Package Manager, rollback Microsoft.AspNetCore.All, Microsoft.AspNetCore.Rewrite, and Microsoft.NETCore.App to versions 2.1.0.

-1
votes

The wildcard version number package references is weird to me. That doesn't happen by default, so either you or one of your team members did that. I don't know if that's the source of at least some of your issues or not, but I'd start by changing them to full version references. NuGet packages are not committed with your project, so having wildcards can lead to strange build issues, particularly in automated builds, when you're developing against one version but a different version is restored later. If you want to upgrade a package, that should be an explicit choice, so you can then verify that all your code still functions as it should post-upgrade.

Also worth noting, since 2.1, code generation has been rolled in, so you should not be explicitly referencing any CodeGen packages.

As far as solving the current issue goes. You may be having some issues with your package cache. In Visual Studio, go to Tools > NuGet Package Manager > Package Management Settings, and then click the "Clear All NuGet Cache(s)" button.

That should prompt a redownload of all your projects NuGet packages, and may be enough to solve the issue. If not, I'd recommend cleaning all your projects and then going into the directory for each and manually deleting both the bin and obj directories. Then, rebuild your solution.

-1
votes

For bugged SDK 2.1.301 version use: <PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.0" /> and force all other packages 2.1.1 -> 2.1.0.