Home > Blockchain >  Docker: The framework 'Microsoft.WindowsDesktop.App', version '3.1.0' (x64) was
Docker: The framework 'Microsoft.WindowsDesktop.App', version '3.1.0' (x64) was

Time:02-10

I have an existing dotnet core 3.1 web app that builds and deploys to an azure app service. it works fine. I am trying to containerize the app.

the build is fine, but when the container runs it gives me

It was not possible to find any compatible framework version
The framework 'Microsoft.WindowsDesktop.App', version '3.1.0' (x64) was not found.
  - No frameworks were found.
You can resolve the problem by installing the specified framework and/or SDK.

my docker

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /source

# copy csproj and restore as distinct layers
COPY myreports/*.csproj .

RUN dotnet restore

# copy and publish app and libraries
COPY . .
RUN dotnet publish -c release -o /app

# final stage/image
FROM mcr.microsoft.com/dotnet/runtime:6.0
WORKDIR /app
COPY --from=build /app .
ENTRYPOINT ["dotnet", "myreports.dll"]

I've tried a variety of docker images(inc dotnet/core) and its the same. my csproj

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <RootNamespace>myreports</RootNamespace>
    <UserSecretsId>ed68b972-ed89-4115-8e6c-5f0d032efa4d</UserSecretsId>
    <DockerDefaultTargetOS>Windows</DockerDefaultTargetOS>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Azure.Storage.Blobs" Version="12.8.0" />
    <PackageReference Include="FastReport.Core3.Web" Version="2021.3.0" />
    <PackageReference Include="Microsoft.ApplicationInsights" Version="2.16.0" />
    <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.16.0" />
    <PackageReference Include="Microsoft.ApplicationInsights.PerfCounterCollector" Version="2.16.0" />
    <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.9" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.9" />
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.9" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.9" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.9">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <!--PackageReference Include="Microsoft.Extensions.Logging.ApplicationInsights" Version="2.14.0" /-->
    <PackageReference Include="Microsoft.AspNetCore.AzureAppServices.HostingStartup" Version="3.1.9" />
    <PackageReference Include="Microsoft.Azure.EventGrid" Version="3.0.0" />
    <PackageReference Include="Microsoft.Azure.Management.ResourceManager" Version="1.6.0-preview" />
    <PackageReference Include="Microsoft.IdentityModel.Clients.ActiveDirectory" Version="4.5.0" />
    <PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.14.0" />
  </ItemGroup>
</Project>

I suspect its this <PackageReference Include="FastReport.Core3.Web" Version="2021.3.0" />

But its required as its core to the project. What gets me is that my config in the (working) app settings is: enter image description here

CodePudding user response:

Your project is targeting .NET Core 3.1 but your Dockerfile is referencing 6.0 tags, which refers to .NET 6. A .NET Core 3.1 app won't be able to run in a 6.0 runtime container. You should update your Dockerfile to reference 3.1 instead of 6.0.

CodePudding user response:

As the package name indicates it is a windows dependant component. Try running your application on a windows container not linux.

CodePudding user response:

I believe I was able to resolve this by changing the final image to :

FROM mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2019

CodePudding user response:

Following your answer on changing the image to mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2019

If you did not change your csproj you now have a .NET Core 3.1 app running on .NET 4.8. This could lead to subtle runtime problems. (citation needed)

I would strongly suggest upgrading your csproj to .NET 6 since .NET 3.1 is running out of support in some months anyways.

I might be mistaken but the first step would be to change <TargetFramework>netcoreapp3.1</TargetFramework> to <TargetFramework>net6.0</TargetFramework> and of course follow an upgrade guide online https://docs.microsoft.com/en-us/aspnet/core/migration/31-to-60?view=aspnetcore-6.0&tabs=visual-studio

  • Related