C# 專案 docker 部署

灵火發表於2024-04-24

開發環境
.net sdk version : 8.0
https://learn.microsoft.com/en-us/dotnet/core/docker/publish-as-container?pivots=dotnet-8-0


修改 csproj 檔案,新增以下內容

<Project Sdk="Microsoft.NET.Sdk.Web">
    
    <PropertyGroup>
        <DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
        <ContainerRepository>app1-web-entry</ContainerRepository>
    </PropertyGroup>

    <PropertyGroup>
        <IsPublishable>true</IsPublishable>
        <EnableSdkContainerSupport>true</EnableSdkContainerSupport>
    </PropertyGroup>
    
    <ItemGroup>
        <Content Include="..\..\.dockerignore">
            <Link>.dockerignore</Link>
        </Content>
    </ItemGroup>

</Project>

相關文章