Soy nuevo en Docker y estaba tratando de migrar mi API escrita en .NET 6 de IIS a Docker.
Entonces escribí un archivo Docker
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base WORKDIR /app FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build WORKDIR /src # copy all the layers' csproj files into respective folders COPY ./VisualOrder.csproj src/ # run restore over API project - this pulls restore over the dependent projects as well RUN dotnet restore "src/VisualOrder.csproj" COPY . . # run build over the API project WORKDIR "/src/" RUN dotnet build -c Release -o /app/build # run publish over the API project FROM build AS publish RUN dotnet publish -c Release -o /app/publish FROM base AS runtime WORKDIR /app COPY --from=publish /app/publish . RUN ls -l ENTRYPOINT [ "dotnet", "VisualOrder.dll" ] Pero el problema es que en RUN dotnet build ... la compilación falla con el siguiente error:
Restaurado /src/VisualOrder.csproj (en 338 ms). #15 1.897 /usr/share/dotnet/sdk/6.0.101/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(356,5): error NETSDK1073: The FrameworkReference 'Microsoft.WindowsDesktop .App' no fue reconocida [/src/VisualOrder.csproj]
Traté de ejecutar dotnet restore en mi PC eliminando las carpetas bin y obj, pero en mi PC todo funciona como debe.
.csproj
<Project Sdk="Microsoft.NET.Sdk.Web"> <PropertyGroup> <TargetFramework>net6.0-windows</TargetFramework> <SignAssembly>false</SignAssembly> <UserSecretsId>d96c762d-ae98-4b1d-a27d-af48bb400d26</UserSecretsId> </PropertyGroup> <ItemGroup> <Content Remove="bundleconfig.json" /> <Content Remove="Views\Emails\EmailNegozio.cshtml" /> <Content Remove="Views\Emails\EmailRiepilogo.cshtml" /> </ItemGroup> <ItemGroup> <_ContentIncludedByDefault Remove="bundleconfig.json" /> </ItemGroup> <ItemGroup> <EmbeddedResource Include="Views\Emails\EmailNegozio.cshtml"> <CopyToOutputDirectory>Always</CopyToOutputDirectory> </EmbeddedResource> <EmbeddedResource Include="Views\Emails\EmailRiepilogo.cshtml"> <CopyToOutputDirectory>Always</CopyToOutputDirectory> </EmbeddedResource> </ItemGroup> <ItemGroup> <None Include="bundleconfig.json" /> </ItemGroup> <ItemGroup> <PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.14.0" /> <PackageReference Include="MySql.Data" Version="8.0.27" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> <PackageReference Include="PayPalCheckoutSdk" Version="1.0.4" /> <PackageReference Include="PayPalHttp" Version="1.0.1" /> <PackageReference Include="QRCoder" Version="1.4.2" /> <PackageReference Include="RazorEngine.NetCore" Version="3.1.0" /> <PackageReference Include="RestSharp" Version="106.13.0" /> <PackageReference Include="Stripe.net" Version="39.80.0" /> <PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" /> </ItemGroup> </Project>Pude resolver el siguiente problema configurando las propiedades del proyecto> tipo de salida> biblioteca de clases
de forma predeterminada, VisualStudio lo establece en 'Aplicación de consola'.