|
41 | 41 | <ContainerRuntimeIdentifier Condition="'$(ContainerRuntimeIdentifier)' == '' and '$(RuntimeIdentifier)' != ''">$(RuntimeIdentifier)</ContainerRuntimeIdentifier>
|
42 | 42 | <ContainerRuntimeIdentifiers Condition="'$(BuildingInsideVisualStudio)' != 'true' and '$(ContainerRuntimeIdentifiers)' == '' and '$(IsRidAgnostic)' != 'true'">$(RuntimeIdentifiers)</ContainerRuntimeIdentifiers>
|
43 | 43 | <ContainerRuntimeIdentifier Condition="'$(ContainerRuntimeIdentifier)' == '' and '$(ContainerRuntimeIdentifiers)' == ''">linux-$(NETCoreSdkPortableRuntimeIdentifier.Split('-')[1])</ContainerRuntimeIdentifier>
|
44 |
| - |
45 |
| - <_ContainerIsUsingMicrosoftDefaultImages Condition="'$(ContainerBaseImage)' == ''">true</_ContainerIsUsingMicrosoftDefaultImages> |
46 |
| - <_ContainerIsUsingMicrosoftDefaultImages Condition="'$(ContainerBaseImage)' != ''">false</_ContainerIsUsingMicrosoftDefaultImages> |
47 | 44 | </PropertyGroup>
|
48 | 45 |
|
49 | 46 | <ItemGroup>
|
|
99 | 96 | <!-- Only default a tag name if no tag names at all are provided -->
|
100 | 97 | <ContainerImageTag Condition="'$(ContainerImageTag)' == '' and '$(ContainerImageTags)' == ''">latest</ContainerImageTag>
|
101 | 98 | <ContainerImageTag Condition="'$(AutoGenerateImageTag)' == 'true' and '$(ContainerImageTags)' == ''">$([System.DateTime]::UtcNow.ToString('yyyyMMddhhmmss'))</ContainerImageTag>
|
102 |
| - |
103 |
| - <!-- 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. |
104 |
| - For builds that have a RID, we default to that RID. Otherwise, we default to the Linux RID matching the architecture of the currently-executing SDK. --> |
105 |
| - <_ContainerIsTargetingWindows>false</_ContainerIsTargetingWindows> |
106 |
| - <_ContainerIsTargetingWindows Condition="$(ContainerRuntimeIdentifier.StartsWith('win'))">true</_ContainerIsTargetingWindows> |
107 |
| - |
108 |
| - <!-- Set the WorkingDirectory depending on the RID --> |
109 |
| - <ContainerWorkingDirectory Condition="'$(ContainerWorkingDirectory)' == '' and !$(_ContainerIsTargetingWindows)">/app/</ContainerWorkingDirectory> |
110 |
| - <ContainerWorkingDirectory Condition="'$(ContainerWorkingDirectory)' == '' and $(_ContainerIsTargetingWindows)">C:\app\</ContainerWorkingDirectory> |
111 |
| - </PropertyGroup> |
112 |
| - |
113 |
| - <!-- We only set a default user when the base image is Microsoft-authored, and we're targeting a version of those images that supports a nonroot user --> |
114 |
| - <PropertyGroup Label="ContainerUser Assignment" Condition="$(_ContainerIsUsingMicrosoftDefaultImages) and $(_ContainerIsTargetingNet8TFM) and '$(ContainerUser)' == ''"> |
115 |
| - <ContainerUser Condition="$(_ContainerIsTargetingWindows)">ContainerUser</ContainerUser> |
116 | 99 | </PropertyGroup>
|
117 | 100 |
|
118 | 101 | <ParseContainerProperties FullyQualifiedBaseImageName="$(ContainerBaseImage)"
|
|
199 | 182 | </PublishContainerDependsOn>
|
200 | 183 | </PropertyGroup>
|
201 | 184 |
|
| 185 | + <!-- These args are relevant to container execution and are per-RID by nature. Therefore they're a direct dependency of the _PublishSingleContainer |
| 186 | + target and not computed at the outer layer. --> |
202 | 187 | <Target Name="_ComputeContainerExecutionArgs">
|
| 188 | + <PropertyGroup> |
| 189 | + <!-- 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. |
| 190 | + For builds that have a RID, we default to that RID. Otherwise, we default to the Linux RID matching the architecture of the currently-executing SDK. --> |
| 191 | + <_ContainerIsTargetingWindows>false</_ContainerIsTargetingWindows> |
| 192 | + <_ContainerIsTargetingWindows Condition="$(ContainerRuntimeIdentifier.StartsWith('win'))">true</_ContainerIsTargetingWindows> |
| 193 | + |
| 194 | + <!-- Set the WorkingDirectory depending on the RID --> |
| 195 | + <ContainerWorkingDirectory Condition="'$(ContainerWorkingDirectory)' == '' and !$(_ContainerIsTargetingWindows)">/app/</ContainerWorkingDirectory> |
| 196 | + <ContainerWorkingDirectory Condition="'$(ContainerWorkingDirectory)' == '' and $(_ContainerIsTargetingWindows)">C:\app\</ContainerWorkingDirectory> |
| 197 | + |
| 198 | + <_ContainerIsUsingMicrosoftDefaultImages Condition="'$(ContainerBaseImage)' == ''">true</_ContainerIsUsingMicrosoftDefaultImages> |
| 199 | + <_ContainerIsUsingMicrosoftDefaultImages Condition="'$(ContainerBaseImage)' != ''">false</_ContainerIsUsingMicrosoftDefaultImages> |
| 200 | + </PropertyGroup> |
| 201 | + |
| 202 | + <!-- We only set a default user when the base image is Microsoft-authored, and we're targeting a version of those images that supports a nonroot user --> |
| 203 | + <PropertyGroup Label="ContainerUser Assignment" Condition="$(_ContainerIsUsingMicrosoftDefaultImages) and $(_ContainerIsTargetingNet8TFM) and '$(ContainerUser)' == ''"> |
| 204 | + <ContainerUser Condition="$(_ContainerIsTargetingWindows)">ContainerUser</ContainerUser> |
| 205 | + </PropertyGroup> |
| 206 | + |
203 | 207 | <ItemGroup Label="AppCommand Assignment" Condition="'$(ContainerAppCommandInstruction)' != 'None'">
|
204 | 208 | <!-- For self-contained, invoke the native executable as a single arg -->
|
205 | 209 | <ContainerAppCommand Condition="@(ContainerAppCommand->Count()) == 0 and $(_ContainerIsSelfContained)" Include="$(ContainerWorkingDirectory)$(AssemblyName)$(_NativeExecutableExtension)" />
|
|
326 | 330 | ContainerRegistry=$(ContainerRegistry);
|
327 | 331 | _ContainerImageTags=@(ContainerImageTags, ';');
|
328 | 332 | ContainerRepository=$(ContainerRepository);
|
329 |
| - ContainerWorkingDirectory=$(ContainerWorkingDirectory); |
330 | 333 | _ContainerLabel=@(ContainerLabel->'%(Identity):%(Value)');
|
331 | 334 | _ContainerPort=@(ContainerPort->'%(Identity):%(Type)');
|
332 | 335 | _ContainerEnvironmentVariables=@(ContainerEnvironmentVariable->'%(Identity):%(Value)');
|
333 |
| - ContainerUser=$(ContainerUser); |
334 | 336 | ContainerGenerateLabels=$(ContainerGenerateLabels);
|
335 | 337 | ContainerGenerateLabelsImageBaseDigest=$(ContainerGenerateLabelsImageBaseDigest);
|
336 | 338 | _SkipContainerPublishing=$(_SkipContainerPublishing)
|
|
0 commit comments