1
votes

A quick preamble, I have seen a number of questions with this error already, but in all cases, these were users that were actually attempting to host asp.net core apps using the wrong container. That is not the case in my situation.

I have a working .net core console app hosted in a docker container that was targeting netcoreapp2.1 I started to update it to netcoreapp3.1 by changing the TargetFramework tag and updating the nuget packages. I also updated the base docker image (.net core runtime) from 2.1 to 3.1.

When I attempt to start this image I get the following error:

It was not possible to find any compatible framework version

The framework 'Microsoft.AspNetCore.App', version '3.1.0' was not found.

No frameworks were found.

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

The specified framework can be found at:

https://aka.ms/dotnet-core-applaunch?framework=Microsoft.AspNetCore.App&framework_version=3.1.0&arch=x64&rid=ubuntu.18.04-x64

The error message is correct that framework is not installed, but it should be looking for Microsoft.NetCore.App, which is installed in the container. It seems that is governed by The value of the Sdk attribute in the Project element in the csproj file which is <Project Sdk="Microsoft.NET.Sdk"> in this project.

What is causing the runtime to look for the wrong framework dependency?

1
It would be helpful to include the relevant parts of your *.csproj file. So if this is actually an ASP.NET application, you'd only need to specify Sdk="Microsoft.NET.Sdk.Web" and you can remove any PackageReference or FrameworkReference to Microsoft.AspNetCore.App. If it's another type of application, you'll need to add <FrameworkReference Include="Microsoft.AspNetCore.App" /> without a version attribute. Does it work locally BTW?Knelis
@Knelis yes it does work locally. As I said in the question, it is NOT an ASP.NET application, it is just a regular console application. It should not be dependent on Microsoft.AspNetCore.App and nothing in visual studio indicates that it is. Microsoft.NetCore.App should be good enough in this case.pquest
You don't need to reference Microsoft.NetCore.App either.Knelis
@Knelis I am not referencing it as a package reference, it is just the value for the sdk attribute in the project tag. I do believe some value is required there.pquest
I am not going to close or answer this yet in case someone actually knows an answer to this, but I was able to fix it by using dotnet new to create a new console project and then copying everything from the old one over. Still not sure what was wrong...pquest

1 Answers

2
votes

The issue was a package reference to Serilog.AspNetCore The netstandard 2.0 version of the package is fine but the netcoreapp 3.1 version takes a framework refernce on Microsoft.AspNetCore.App:

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
    <PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="2.1.1" />
    <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.1.1" />
    <PackageReference Include="Microsoft.Extensions.Logging" Version="2.1.1" />
  </ItemGroup>

  <ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
    <FrameworkReference Include="Microsoft.AspNetCore.App" />
    
    <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.2" />
    <PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.2" />
  </ItemGroup>

This dependency doesn't seem to be visible anywhere, which was why it was so difficult to track down. Removing the package, which didn't seem to actually be needed solved the problem.