aspnetcore: The framework 'Microsoft.NETCore.App', version '2.0.0' was not found. Migration to 3.1

Describe the bug

Migration from 2.2 to 3.1. Project Sdk as Microsoft.NET.Sdk. Reference <FrameworkReference Include="Microsoft.AspNetCore.App"/> searches for aspnet 2.0.0 when building:

SoftinuxBase.Security.Common -> F:\Developpement\Base\src\SoftinuxBase.Security.Common\bin\Debug\netcoreapp3.1\SoftinuxBase.Security.Common.dll
  It was not possible to find any compatible framework version
  The framework 'Microsoft.NETCore.App', version '2.0.0' was not found.
    - The following frameworks were found:
        3.0.0 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
        3.1.0 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
        3.1.1 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

  You can resolve the problem by installing the specified framework and/or SDK.

The csproj:

<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
    <Version>0.0.1</Version>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <AssemblyName>SoftinuxBase.Security.Common</AssemblyName>
    <RootNamespace>SoftinuxBase.Security.Common</RootNamespace>
    <PackageId>SoftinuxBase.Security.Common</PackageId>
  </PropertyGroup>
  <PropertyGroup>
    <LangVersion>8</LangVersion>
    <CodeAnalysisRuleSet>..\..\StyleCopRules.ruleset</CodeAnalysisRuleSet>
    <RepositoryUrl>https://github.com/SOFTINUX/Base</RepositoryUrl>
  </PropertyGroup>
  <ImportGroup Label="Documentation">
    <Import Project="..\..\documentation.props" />
  </ImportGroup>
  <ItemGroup>
    <AdditionalFiles Include="..\..\stylecop.json" />
  </ItemGroup>
  <ItemGroup>
    <FrameworkReference Include="Microsoft.AspNetCore.App"/>
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
    </PackageReference>
  </ItemGroup>

</Project>

Further technical details

SDK .NET Core (reflétant tous les global.json) :
 Version:   3.1.101
 Commit:    b377529961

Environnement d'exécution :
 OS Name:     Windows
 OS Version:  10.0.18363
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.1.101\

Host (useful for support):
  Version: 3.1.1
  Commit:  a1388f194c

.NET Core SDKs installed:
  3.0.100 [C:\Program Files\dotnet\sdk]
  3.1.100 [C:\Program Files\dotnet\sdk]
  3.1.101 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

SDK:

3.0.100 [C:\Program Files\dotnet\sdk]
3.1.100 [C:\Program Files\dotnet\sdk]
3.1.101 [C:\Program Files\dotnet\sdk]

IDE: vscode, visual studio 2019, rider 2019.3.1

Build mode: by command line with cleaning /bin, /obj folders before for give correct references


I use IAuthorizationFilter for filter claims (from Identity)

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 2
  • Comments: 18 (7 by maintainers)

Most upvoted comments

Hi, I continue my investigations.

I discover that Visual Studio 2019 add’s Microsoft.AspNetCore.App 2.1.15 after repairing. So, you can never have this error when VS2019 is installed. image

But, on Linux, you cannot have VS2019 and you have this error. I suppose it’s same on Mac.

It’s a real problem to have multiple versions of the sdk. This implies that when you carry out an asp project in 2.1 that then you change the runtime to 3.1 in the csproj, somewhere, there is a strong relationship on the sdk / runtime 2.1

In the migration documentation 2.1 -> 3.1, nothing is indicated on this subject.

I can no longer confirm, but it seems to me that I had tested a template project in 2.1 directly passed to 3.1 without other modifications than those indicated in the documentation of migration from 2.1 to 3.1 and that the problem was present.

In release mode, do you have a full 3.1 package or a 2.1 / 3.1 mix?

@NTaylorMullen, sorry I didn’t give me time to try it now. I will try this today to see if it persists and give you feedback.

I’m pretty sure we addressed this in .NET 5.

We’ve done a lot in the .NET 5 time frame and although I personally didn’t do the work to enable it I wouldn’t be surprised if it was fixed either.

@tremblaysimon would you mind trying to install the .NET 5 preview SDK to see if the issue persists? If it does that definitely wouldn’t be ideal 😄

Tagging @NTaylorMullen on this stale issue. I think the issue is that tools like rzc which used to be in packages didn’t have automatic roll-forward to the next major runtime.

I’m pretty sure we addressed this in .NET 5.

@davidfowl, maybe the word odd is not the right one.

What I wanted to say is more about the fact that when we have a webapi created with 2.1 sdk for example we can easily buid it using an image that contains only the .NET Core 3.1 sdk.

But if you have some razor pages created using 2.1 sdk you will not be able to achieve a build with .NET Core 3.1 sdk. You must get the runtime for 2.1 too to achieve that.

In the end, I think it’s more something I didn’t understand (or found in an official doc) about backward-compatibility or not of .NET Core 3.1 sdk with the previous ones.