prom3theu5 / aspirational-manifests

Handle deployments of .NET Aspire AppHost Projects
MIT License
702 stars 36 forks source link

Will not publish containers for non-web projects #219

Closed jaydeboer closed 5 months ago

jaydeboer commented 5 months ago

🔥 Bug Description

Our application is a mixture of projects of <Project Sdk="Microsoft.NET.Sdk.Web"> and <Project Sdk="Microsoft.NET.Sdk"> types. All Microsoft.NET.Sdk project types display A publish profile with the name 'DefaultContainer' was not found in the project. Set the PublishProfile property to a valid file name. and do not push a container to the repository during aspirate build

🔍 Steps to Reproduce the Bug

  1. Have a <Project Sdk="Microsoft.NET.Sdk"> project referenced in your AppHost project.
  2. Run aspirate build
  3. See the error in the output of the command
  4. Try aspirate apply and no container will be running because it isn't in the repository.

🧯 Possible Solution

jaydeboer commented 5 months ago

I've found that if you change the project type to <Project Sdk="Microsoft.NET.Sdk.Worker"> you can get around the issue.

prom3theu5 commented 5 months ago

Seems like they fixed this in 8.0.200, so that all project types can now use /t:PublishContainer https://github.com/dotnet/sdk-container-builds/issues/141

I'll get it changed - cheers :)

prom3theu5 commented 5 months ago

This has just gone out in v8.0.4 (nuget in ten mins or so)

One thing you will have to do though for Sdk (console) apps. You have to opt in to container support as per the docs here: https://learn.microsoft.com/en-us/dotnet/core/docker/publish-as-container?pivots=dotnet-8-0

You don't need to add the containers nuget package as its backed into the sdk, but you have to add

<PropertyGroup>
  <IsPublishable>true</IsPublishable>
  <EnableSdkContainerSupport>true</EnableSdkContainerSupport>
</PropertyGroup>

CleanShot 2024-06-07 at 23 51 24

CleanShot 2024-06-07 at 23 52 04