'The framework 'Microsoft.WindowsDesktop.App', version '6.0.0' (x64) was not found in docker image

I have created a webapi project in dot net 6.0, which internally uses some winform code. I want to create a docker image however it is throwing the following error:

It was not possible to find any compatible framework version The framework 'Microsoft.WindowsDesktop.App', version '6.0.0' (x64) was not found.

  • No frameworks were found.

How I can add Microsoft.WindowsDesktop.App to my docker image?

FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["Test.Service/Test.Service.csproj", "Test.Service/"]
RUN dotnet restore "Test.Service/Test.Service.csproj"
COPY . .
WORKDIR "/src/Test.Service"
RUN dotnet build "Test.Service.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "Test.Service.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Test.Service.dll"]

<PropertyGroup>
    <TargetFramework>net6.0-windows</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <UserSecretsId>4948d1e0-055d-48fa-98c8-a606d62afdc5</UserSecretsId>
    <DockerDefaultTargetOS>Windows</DockerDefaultTargetOS>
    <UseWindowsForms>true</UseWindowsForms>
  </PropertyGroup>


Solution 1:[1]

The framework 'Microsoft.WindowsDesktop.App', version '6.0.0' (x64) was not found in docker image

  • If you only install .NET 6.0 runtime, it won't install the related .NET 6.0 Desktop runtime.
  • Install .Net 6 SDK
  • If you already have it, try to re-install

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1