-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't run ContainerPublish
in solution with multi targeting
#578
Comments
Hi, sorry for the delay here - publishing containers doesn't currently work with multi-targeting out of the box, you'd need to publish for a specific TFM, which I know doesn't work super-great with solution-level publishing. We'll need to do some work here to light this up. One question we'd need to answer for multi-TFM publishing is - how should the ContainerImageTag(s) be inferred when multi-targeting? Take for example a Web SDK project name ProposalsPrepend TFM to each default-generated tagBy default we infer the Append TFM to each default-generated tagBy default we infer the Do not allow defaults for multi-targeted image buildsWith this proposal, we would require the user to set a <PropertyGroup>
<ContainerImageTag Condition="$(TargetFrameworkVersion) == 'net9.0">speedy</ContainerImageTag>
<ContainerImageTag Condition="$(TargetFrameworkVersion) == 'net8.0">normal</ContainerImageTag>
</PropertyGroup> In this mode, we would error if a user tried a multi-TFM build without specifying Thoughts?Would love feedback on these proposals - what do users expect to happen? |
Sorry for not responding sooner. Honestly I'm not too fussed how multi target builds work for containers. My main concern is that if I have a multi targeted class library marked as So specifically if a solution contains the following project <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0;net472</TargetFrameworks>
<IsPublishable>false</IsPublishable>
</PropertyGroup>
</Project> I'd expect that to be ignored because I've explicitly marked it as not publishable - the container publishing process can ignore the project long before the complication of multi targeted container publishing comes up. In terms of multi targeted container builds, I'd personally want to manually control tags rather than have an automated one applied. I'll pick one framework version and ship that and not give my users the choice. I guess the only time I can think of is a brief transition period, but in that time I'd still want one of the frameworks to remain the If you do go with an automated prefix/suffix then I'd rather see |
A fourth proposal could be to allow one of the target frameworks to be specified as "Primary". This will then be left without a prefix (e.g. |
Ah yes, this makes perfect sense. We should do this at a minimum! |
#37072 was merged to allow you to run
dotnet publish /t:ContainerPublish
against a solution and have it ignore projects in which SDK Container Publishing was not enabled.Whilt this works for many projects, if your solution has any multi targeted projects (e.g.
<TargetFrameworks>net472;netstandard2.0;net6.0;net8.0</TargetFrameworks>
), trying to publish the solution fails on the multi targeted project(s)Looking at the bin log, the SDK declined to import
Microsoft.NET.Build.Containers.targets
. (although oddly it did importMicrosoft.NET.Build.Containers.props
)Interestingly, whilst the
Microsoft.NET.Build.Containers.targets
wasn't imported,Microsoft.NET.Build.Containers.props
was - I'd expect either both or neither of these files to be imported, and not just one.(Note a space was added in
$(_ContainerTargetsDir)
above as otherwise github tired to format it as a mathematical equation.The problem seems to be that the target import includes a
'$(TargetFramework)' != ''"
check https://github.com/dotnet/sdk/blob/3cfb3ea0bf20d99ffba14e1cb56e07f0806ce1eb/src/Tasks/Microsoft.NET.Build.Tasks/sdk/Sdk.targets#L65To be clear, if Publishing Containers doesn't work with multi targeting, that's fine by me. However I'm expecting the target to be there and be a no-op if
IsPublishable == false
or if the project doesn't have container configuration.The text was updated successfully, but these errors were encountered: