pquest
pquest

Reputation: 3290

Console App Updated to .Net Core 3.1 Error The framework 'Microsoft.AspNetCore.App', version '3.1.0' was not found

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?

Upvotes: 2

Views: 2005

Answers (1)

pquest
pquest

Reputation: 3290

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.

Upvotes: 4

Related Questions