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

Container image: save built image ID #493

Open weikanglim opened 1 year ago

weikanglim commented 1 year ago

Related to https://github.com/Azure/azure-dev/issues/2632

Suppose that a user or tool wants to run dotnet publish -p:PublishProfile=DefaultContainer to build the image locally, and then publish it in a subsequent step outside of dotnet publish. In this case, it'd be nice for there to be a way to reference the unique image ID produced. Currently, there are output MSBuild task variables present , but it'd be nice to have the reference available outside of being part of MSBuild process.

To support an external tool invocation, I could see something like dotnet publish -p:PublishProfile=DefaultContainer -p:IIDFile=<path> similar to docker build --iidfile useful.

baronfel commented 1 year ago

The new MSBuild CLI Evaluation work might actually make this even easier - I think you'd be able to run a publish command and request specific properties/items from the build, and have that returned back to you in structured form, all without us needing to write any files.

>dotnet publish --os linux --arch x64 -p PublishProfile=DefaultContainer -getProperty GeneratedContainerManifest
{ .... }

This is only coming in .NET 8.0.100 RC2+ at this point though, so it's not immediately usable, and would limit your audience to those with .NET 8 installed. I'm unsure how viable that answer is for you.