Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to switch Visual Studio project from Windows to Linux container?

How to switch Visual Studio 2019 project file from Windows to Linux container?

I got Error CTC1005 in Visual Studio 2019, project ASP.NET Core 3.0 Your Docker server host is configured for 'Linux', however your project is configured for Windows.

Desktop Docker running Linux containers. The Docker file supports Linux container. Here it is:

FROM mcr.microsoft.com/dotnet/core/aspnet:3.0-buster-slim AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/core/sdk:3.0-buster AS build
WORKDIR /src
COPY ["WebApplication1/WebApplication1.csproj", "WebApplication1/"]
RUN dotnet restore "WebApplication1/WebApplication1.csproj"
COPY . .
WORKDIR "/src/WebApplication1"
RUN dotnet build "WebApplication1.csproj" -c Release -o /app/build

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

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "WebApplication1.dll"]
like image 694
Michael Chudinov Avatar asked Oct 31 '25 05:10

Michael Chudinov


1 Answers

Edit your .csproj file and you will see that the docker OS is in there, just change <DockerDefaultTargetOS> to Linux ie.

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
    <DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
    ...
   </PropertyGroup>

   ...
</Project>
like image 73
Leo Avatar answered Nov 02 '25 19:11

Leo