dotnet / sdk-container-builds

Libraries and build tooling to create container images from .NET projects using MSBuild
https://learn.microsoft.com/en-us/dotnet/core/docker/publish-as-container
MIT License
179 stars 34 forks source link

Console applications should be able to be packaged by default #513

Closed baronfel closed 10 months ago

baronfel commented 11 months ago

The Container targets aren't imported by console applications in the base .NET SDK, and so the PublishContainer target isn't usable for them. We should push the Import of these props/targets down into the Base SDK so that multi-project orchestration scenarios and console publishing works.

MichalPavlik commented 10 months ago

I have been searching for the appropriate location, and I believe that the Microsoft.NET.Sdk.targets file is the one to which we should move our import. Additionally, if my memory serves me correctly, we intended to add IsPublishable AND EnableSdkContainerSupport to the import condition.

baronfel commented 10 months ago

That sounds like a good location to me - and a big +1 on the EnableSdkContainerSupport flag as well. One thing to check - is the Publish SDK imported before or after the Microsoft.NET.Sdk.Targets? I ask because if we add EnableSdkContainerSupport checks, then we will want to make sure that the Publish SDK (which sets EnableSdkContainerSupport to true when imported) is still Imported before the Container targets' Condition is evaluated.