Skip to content

.NET

Create a PublishProfile such as ghcr.pubxml

<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<WebPublishMethod>Container</WebPublishMethod>
<ContainerPublishMethod>NetSdk</ContainerPublishMethod>
<ContainerBaseImage>mcr.microsoft.com/dotnet/aspnet:8.0</ContainerBaseImage>
<ContainerRepository>YOURUSER/YOURPACKAGE</ContainerRepository>
<RegistryUrl>ghcr.io</RegistryUrl>
<UserName>YOURUSER</UserName>
<PublishImageTag>latest</PublishImageTag>
<PublishProvider>ContainerRegistry</PublishProvider>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
<ProjectGuid>123d0968-84f9-4858-bd7a-df45893ea1f8</ProjectGuid>
<_TargetId>NetSdkCustomContainerRegistry</_TargetId>
<ExcludeApp_Data>false</ExcludeApp_Data>
<TargetFramework>net8.0</TargetFramework>
<SelfContained>true</SelfContained>
</PropertyGroup>
</Project>

To build and push to registry, use: dotnet publish --os linux --arch x64 -c Release /p:PublishProfile=ghcr

Programming