sdk-container-builds
sdk-container-builds copied to clipboard
Cannot specify ContainerEnvironmentVariable via the command line using -p:ContainerEnvironmentVariable=?
For automating builds and deploys it would be useful if we can specify container environment variables via the command line. Such as:
dotnet publish --os linux --arch x64 -p:ContainerEnvironmentVariable=EnvironmentVariable=Value /t:PublishContainer -c Release
How can this be done via the command line since that property is a complex property?
<ContainerEnvironmentVariable Include="ASPNETCORE_ENVIRONMENT" Value="Development" />
But when building for other environments i would like to set it to a different value such as the below:
<ContainerEnvironmentVariable Include="ASPNETCORE_ENVIRONMENT" Value="Staging" />
Are there any workarounds or other means to achieve this?
Hi @lymberl - currently this is not possible. MSBuild doesn't allow passing Items on the command line. @rainersigwald are there patterns that we could rely on here? Or I suppose in the worst case we could do something like
- have a property that users could set
- have a target that explicitly 'splits' that property into Items by parsing a specific format.
- have a property that users could set
- have a target that explicitly 'splits' that property into Items by parsing a specific format.
This is the best I can think of too; it's nice and explicit.
How confusing would it be if we chose the Property name of ContainerEnvironmentVariable as well? Does MSBuild handle the ambiguity correctly based on how the name is used, either in @() for items or $() for Properties?
Otherwise I suppose that would impact the choice of name for the property to use here.
Yes, we have totally separate lookup tables so you can have a property and an item with the same name. It tends to be pretty confusing to debug (even more than getting it wrong when there's only one but it's the other kind) but in this case I think that's outweighed by the consistency of naming.
We need something like this for CI/CD, as is we need to stick to docker based container builds to inject environment variables.
Is it resolved?, we are facing the same issue on providing ContainerEnvironmentVariable in the command line to set ASPNETCORE_ENVIRONMENT Environment variable.