From ad1d149ee075e529eaa2f25a3ccc98302e4e6d59 Mon Sep 17 00:00:00 2001 From: Eric Erhardt Date: Wed, 12 Nov 2025 13:41:36 -0600 Subject: [PATCH 1/2] Set RuntimeIdentifier when building dotnet containers Set both RuntimeIdentifier/ContainerRuntimeIdentifier or RuntimeIdentifiers/ContainerRuntimeIdentifiers when building dotnet containers. This way the application is published correctly - for example for native AOT. --- playground/TestShop/BasketService/BasketService.csproj | 1 - playground/TestShop/CatalogService/CatalogService.csproj | 1 - playground/TestShop/MyFrontend/MyFrontend.csproj | 1 - .../Publishing/ResourceContainerImageBuilder.cs | 8 +++++--- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/playground/TestShop/BasketService/BasketService.csproj b/playground/TestShop/BasketService/BasketService.csproj index 481d40e7d7e..91670be9ed4 100644 --- a/playground/TestShop/BasketService/BasketService.csproj +++ b/playground/TestShop/BasketService/BasketService.csproj @@ -3,7 +3,6 @@ $(DefaultTargetFramework) f0611710-1eab-4ff6-a476-9610bb7a8416 - localhost:5001 basket-service mcr.microsoft.com/dotnet/aspnet:8.0 diff --git a/playground/TestShop/CatalogService/CatalogService.csproj b/playground/TestShop/CatalogService/CatalogService.csproj index 4a3b7120bbb..205c4412a3d 100644 --- a/playground/TestShop/CatalogService/CatalogService.csproj +++ b/playground/TestShop/CatalogService/CatalogService.csproj @@ -4,7 +4,6 @@ $(DefaultTargetFramework) 16965dbf-c1f8-4682-b7d8-e250ac520544 preview - localhost:5001 catalog-service mcr.microsoft.com/dotnet/aspnet:8.0 diff --git a/playground/TestShop/MyFrontend/MyFrontend.csproj b/playground/TestShop/MyFrontend/MyFrontend.csproj index 2b9eaeb624c..95172547829 100644 --- a/playground/TestShop/MyFrontend/MyFrontend.csproj +++ b/playground/TestShop/MyFrontend/MyFrontend.csproj @@ -2,7 +2,6 @@ $(DefaultTargetFramework) - localhost:5001 my-frontend mcr.microsoft.com/dotnet/aspnet:8.0 diff --git a/src/Aspire.Hosting/Publishing/ResourceContainerImageBuilder.cs b/src/Aspire.Hosting/Publishing/ResourceContainerImageBuilder.cs index 4826a91da63..9955c0123e6 100644 --- a/src/Aspire.Hosting/Publishing/ResourceContainerImageBuilder.cs +++ b/src/Aspire.Hosting/Publishing/ResourceContainerImageBuilder.cs @@ -273,19 +273,21 @@ private async Task ExecuteDotnetPublishAsync(IResource resource, Container if (options.TargetPlatform is not null) { - // Use the appropriate MSBuild property based on the number of RIDs + // Use the appropriate MSBuild properties based on the number of RIDs var runtimeIds = options.TargetPlatform.Value.ToMSBuildRuntimeIdentifierString(); var ridArray = runtimeIds.Split(';'); if (ridArray.Length == 1) { - // Single platform - use ContainerRuntimeIdentifier + // Single platform - use RuntimeIdentifier/ContainerRuntimeIdentifier + arguments += $" /p:RuntimeIdentifier=\"{ridArray[0]}\""; arguments += $" /p:ContainerRuntimeIdentifier=\"{ridArray[0]}\""; } else { - // Multiple platforms - use RuntimeIdentifiers + // Multiple platforms - use RuntimeIdentifiers/ContainerRuntimeIdentifiers arguments += $" /p:RuntimeIdentifiers=\"{runtimeIds}\""; + arguments += $" /p:ContainerRuntimeIdentifiers=\"{runtimeIds}\""; } } } From f046df95f402f145d5ebe6ebb2f1847183068f8d Mon Sep 17 00:00:00 2001 From: Eric Erhardt Date: Wed, 12 Nov 2025 17:46:40 -0600 Subject: [PATCH 2/2] Apply suggestion from @eerhardt --- .../Publishing/ResourceContainerImageBuilder.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Aspire.Hosting/Publishing/ResourceContainerImageBuilder.cs b/src/Aspire.Hosting/Publishing/ResourceContainerImageBuilder.cs index 9955c0123e6..0c8b30f7e6f 100644 --- a/src/Aspire.Hosting/Publishing/ResourceContainerImageBuilder.cs +++ b/src/Aspire.Hosting/Publishing/ResourceContainerImageBuilder.cs @@ -286,8 +286,9 @@ private async Task ExecuteDotnetPublishAsync(IResource resource, Container else { // Multiple platforms - use RuntimeIdentifiers/ContainerRuntimeIdentifiers - arguments += $" /p:RuntimeIdentifiers=\"{runtimeIds}\""; - arguments += $" /p:ContainerRuntimeIdentifiers=\"{runtimeIds}\""; + // MSBuild doesn't handle ';' in parameters well, need to escape the double quote. See https://github.com/dotnet/msbuild/issues/471 + arguments += $" /p:RuntimeIdentifiers=\\\"{runtimeIds}\\\""; + arguments += $" /p:ContainerRuntimeIdentifiers=\\\"{runtimeIds}\\\""; } } }