|
23 | 23 | <Error Condition="'$(_IsSDKContainerAllowedVersion)' != 'true'" Code="CONTAINER002" Text="The current .NET SDK ($(NETCoreSdkVersion)) doesn't support containerization. Please use version 7.0.100 or higher to enable containerization." />
|
24 | 24 | </Target>
|
25 | 25 |
|
26 |
| - <Target Name="_ContainerVerifyRuntime" |
27 |
| - Condition="'$(WebPublishMethod)' == 'Container' or '$(PublishProfile)' == 'DefaultContainer'" |
28 |
| - BeforeTargets="AfterPublish"> |
29 |
| - <!-- https://github.com/dotnet/sdk-container-builds/issues/91 --> |
30 |
| - <Error Condition="'$(RuntimeIdentifier)' != 'linux-x64'" Code="CONTAINER006" Text="The Microsoft.NET.Build.Containers package does not (yet) support publishing for $([MSBuild]::ValueOrDefault('$(RuntimeIdentifier)', 'portable or no-RuntimeIdentifier-defined scenarios')). Please specify a runtime of "linux-x64"" /> |
31 |
| - </Target> |
32 |
| - |
33 | 26 | <Target Name="ComputeContainerConfig">
|
34 | 27 | <!-- Reference data about this project -->
|
35 | 28 | <PropertyGroup>
|
|
51 | 44 | <ContainerRegistry Condition="'$(RegistryUrl)' != ''">$(RegistryUrl)</ContainerRegistry>
|
52 | 45 | <!-- PublishImageTag is used by existing VS targets for Docker builds - this lets us fill that void -->
|
53 | 46 | <ContainerImageTag Condition="'$(PublishImageTag)' != ''">$(PublishImageTag)</ContainerImageTag>
|
| 47 | + <!-- This line is a compatibility shim for VS support - the VS container targets define a container tag using this property and format. This lets us be a drop-in replacement for them. --> |
| 48 | + <ContainerImageTag Condition="'$(AutoGenerateImageTag)' == 'true'">$([System.DateTime]::UtcNow.ToString('yyyyMMddhhmmss'))</ContainerImageTag> |
54 | 49 | </PropertyGroup>
|
55 | 50 |
|
56 | 51 | <!-- Container Defaults -->
|
|
64 | 59 | <ContainerImageName Condition="'$(ContainerImageName)' == ''">$(AssemblyName)</ContainerImageName>
|
65 | 60 | <!-- Only default a tag name if no tag names at all are provided -->
|
66 | 61 | <ContainerImageTag Condition="'$(ContainerImageTag)' == '' and '$(ContainerImageTags)' == ''">$(Version)</ContainerImageTag>
|
67 |
| - <ContainerImageTag Condition="'$(AutoGenerateImageTag)' == 'true'">$([System.DateTime]::UtcNow.ToString('yyyyMMddhhmmss'))</ContainerImageTag> |
68 | 62 | <ContainerWorkingDirectory Condition="'$(ContainerWorkingDirectory)' == ''">/app</ContainerWorkingDirectory>
|
69 |
| - <!-- Could be semicolon-delimited --> |
| 63 | + <!-- The Container RID should default to the RID used for the entire build (to ensure things run on the platform they are built for), but the user knows best and so should be able to set it explicitly. |
| 64 | + For builds that have a RID, we default to that RID. Otherwise, we default to the RID of the currently-executing SDK. --> |
| 65 | + <ContainerRuntimeIdentifier Condition="'$(ContainerRuntimeIdentifier)' == '' and '$(IsRidAgnostic)' == 'true'">$(RuntimeIdentifier)</ContainerRuntimeIdentifier> |
| 66 | + <ContainerRuntimeIdentifier Condition="'$(ContainerRuntimeIdentifier)' == '' ">$(NETCoreSdkPortableRuntimeIdentifier)</ContainerRuntimeIdentifier> |
70 | 67 | </PropertyGroup>
|
71 | 68 |
|
72 | 69 | <ItemGroup Label="Entrypoint Assignment">
|
|
77 | 74 | </ItemGroup>
|
78 | 75 |
|
79 | 76 | <ItemGroup Label="Conventional Label assignment">
|
| 77 | + <!-- TODO: This impacts build reproducibility - it should probably be settable/conditioned on a property --> |
80 | 78 | <ContainerLabel Include="org.opencontainers.image.created" Value="$([System.DateTime]::UtcNow.ToString('o'))" />
|
81 | 79 | </ItemGroup>
|
82 | 80 |
|
|
108 | 106 | <PropertyGroup>
|
109 | 107 | <PublishContainerDependsOn>
|
110 | 108 | _ContainerVerifySDKVersion;
|
111 |
| - _ContainerVerifyRuntime; |
112 | 109 | ComputeContainerConfig
|
113 | 110 | </PublishContainerDependsOn>
|
114 | 111 | </PropertyGroup>
|
|
137 | 134 | Labels="@(ContainerLabel)"
|
138 | 135 | ExposedPorts="@(ContainerPort)"
|
139 | 136 | ContainerEnvironmentVariables="@(ContainerEnvironmentVariables)"
|
140 |
| - ContainerRuntimeIdentifier="$(RuntimeIdentifier)"> |
| 137 | + ContainerRuntimeIdentifier="$(ContainerRuntimeIdentifier)"> |
141 | 138 | <Output TaskParameter="GeneratedContainerManifest" PropertyName="GeneratedContainerManifest" />
|
142 | 139 | <Output TaskParameter="GeneratedContainerConfiguration" PropertyName="GeneratedContainerConfiguration" />
|
143 | 140 | </CreateNewImage>
|
|
0 commit comments