dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.68k stars 1.06k forks source link

DOTNET PUBLISH doesn't add tags on docker container when using an environment variable that contains multiple tags #37610

Open keigezellig opened 9 months ago

keigezellig commented 9 months ago

Describe the bug

I am using dotnet publish to create and publish a docker container for a Blazor WebApp. When setting the ContainerImageTag option through an environment variable which contains multiple tags (formatted according to the documentation), those tags are not put on the resulting docker image. This occurs when building locally as well using the .net SDK docker to build the app in my CI/CD environment.

See screenshot below

image

To Reproduce

I created a minimal Blazor project (to be found here) that reproduces the issue in a couple of scenarios. Run the deploy.sh to see what happens. The actual dotnet publish commands are also to found in this file.

Further technical details

Output of dotnet --info (my local system)

.NET SDK: Version: 8.0.100 Commit: 57efcf1350 Workload version: 8.0.100-manifests.3b83835e

Runtime Environment: OS Name: ubuntu OS Version: 22.04 OS Platform: Linux RID: linux-x64 Base Path: /usr/share/dotnet/sdk/8.0.100/

.NET workloads installed: Workload version: 8.0.100-manifests.3b83835e [maui-android] Installation Source: SDK 8.0.100 Manifest Version: 8.0.3/8.0.100 Manifest Path: /usr/share/dotnet/sdk-manifests/8.0.100/microsoft.net.sdk.maui/8.0.3/WorkloadManifest.json Install Type: FileBased

[wasm-tools] Installation Source: SDK 8.0.100 Manifest Version: 8.0.0/8.0.100 Manifest Path: /usr/share/dotnet/sdk-manifests/8.0.100/microsoft.net.workload.mono.toolchain.current/8.0.0/WorkloadManifest.json Install Type: FileBased

Host: Version: 8.0.0 Architecture: x64 Commit: 5535e31a71

.NET SDKs installed: 8.0.100 [/usr/share/dotnet/sdk]

.NET runtimes installed: Microsoft.AspNetCore.App 8.0.0 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 8.0.0 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found: None

Environment variables: DOTNET_ROOT [/usr/share/dotnet]

global.json file: Not found

Learn more: https://aka.ms/dotnet/info

Download .NET: https://aka.ms/dotnet/download

baronfel commented 9 months ago

Hi @keigezellig - what you've found here is actually a bug in our validation code. None of the ways you're passing multiple tags are making it through to the containerization targets. I've got a PR to fix this validation at https://github.com/dotnet/sdk/pull/37832, but I'll have to dig for an example of correctly passing them through the command line. There's some other discussion here that may help: https://github.com/dotnet/sdk-container-builds/issues/492#issuecomment-1682804769