|
39 | 39 | <ContainerRuntimeIdentifier Condition="'$(ContainerRuntimeIdentifier)' == '' and '$(RuntimeIdentifier)' != ''">$(RuntimeIdentifier)</ContainerRuntimeIdentifier>
|
40 | 40 | <ContainerRuntimeIdentifiers Condition="'$(BuildingInsideVisualStudio)' != 'true' and '$(ContainerRuntimeIdentifiers)' == '' and '$(IsRidAgnostic)' != 'true'">$(RuntimeIdentifiers)</ContainerRuntimeIdentifiers>
|
41 | 41 | <ContainerRuntimeIdentifier Condition="'$(ContainerRuntimeIdentifier)' == '' and '$(ContainerRuntimeIdentifiers)' == ''">linux-$(NETCoreSdkPortableRuntimeIdentifier.Split('-')[1])</ContainerRuntimeIdentifier>
|
42 |
| - |
43 |
| - <_ContainerIsUsingMicrosoftDefaultImages Condition="'$(ContainerBaseImage)' == ''">true</_ContainerIsUsingMicrosoftDefaultImages> |
44 |
| - <_ContainerIsUsingMicrosoftDefaultImages Condition="'$(ContainerBaseImage)' != ''">false</_ContainerIsUsingMicrosoftDefaultImages> |
45 | 42 | </PropertyGroup>
|
46 | 43 |
|
47 | 44 | <ItemGroup>
|
|
97 | 94 | <!-- Only default a tag name if no tag names at all are provided -->
|
98 | 95 | <ContainerImageTag Condition="'$(ContainerImageTag)' == '' and '$(ContainerImageTags)' == ''">latest</ContainerImageTag>
|
99 | 96 | <ContainerImageTag Condition="'$(AutoGenerateImageTag)' == 'true' and '$(ContainerImageTags)' == ''">$([System.DateTime]::UtcNow.ToString('yyyyMMddhhmmss'))</ContainerImageTag>
|
100 |
| - |
101 |
| - <!-- 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. |
102 |
| - 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. --> |
103 |
| - <_ContainerIsTargetingWindows>false</_ContainerIsTargetingWindows> |
104 |
| - <_ContainerIsTargetingWindows Condition="$(ContainerRuntimeIdentifier.StartsWith('win'))">true</_ContainerIsTargetingWindows> |
105 |
| - |
106 |
| - <!-- Set the WorkingDirectory depending on the RID --> |
107 |
| - <ContainerWorkingDirectory Condition="'$(ContainerWorkingDirectory)' == '' and !$(_ContainerIsTargetingWindows)">/app/</ContainerWorkingDirectory> |
108 |
| - <ContainerWorkingDirectory Condition="'$(ContainerWorkingDirectory)' == '' and $(_ContainerIsTargetingWindows)">C:\app\</ContainerWorkingDirectory> |
109 |
| - </PropertyGroup> |
110 |
| - |
111 |
| - <ItemGroup Label="AppCommand Assignment" Condition="'$(ContainerAppCommandInstruction)' != 'None'"> |
112 |
| - <!-- For self-contained, invoke the native executable as a single arg --> |
113 |
| - <ContainerAppCommand Condition="@(ContainerAppCommand->Count()) == 0 and $(_ContainerIsSelfContained)" Include="$(ContainerWorkingDirectory)$(AssemblyName)$(_NativeExecutableExtension)" /> |
114 |
| - <!-- For non self-contained, invoke `dotnet` `app.dll` as separate args --> |
115 |
| - <ContainerAppCommand Condition="@(ContainerAppCommand->Count()) == 0 and !$(_ContainerIsSelfContained)" Include="dotnet;$(ContainerWorkingDirectory)$(TargetFileName)" /> |
116 |
| - </ItemGroup> |
117 |
| - |
118 |
| - <!-- 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 --> |
119 |
| - <PropertyGroup Label="ContainerUser Assignment" Condition="$(_ContainerIsUsingMicrosoftDefaultImages) and $(_ContainerIsTargetingNet8TFM) and '$(ContainerUser)' == ''"> |
120 |
| - <ContainerUser Condition="$(_ContainerIsTargetingWindows)">ContainerUser</ContainerUser> |
121 | 97 | </PropertyGroup>
|
122 | 98 |
|
123 | 99 | <ParseContainerProperties FullyQualifiedBaseImageName="$(ContainerBaseImage)"
|
|
184 | 160 | </ItemGroup>
|
185 | 161 |
|
186 | 162 | <!-- These sourcelink-derived properties are only allowed to flow to generated artifacts if `PublishRepositoryUrl` is set as a user signal for opt-in.
|
187 |
| - In addition, the 'nice' property names are currently set by NuGet Pack targets and so we have to use the private/generic names here. --> |
| 163 | + In addition, the 'nice' property names are currently set by NuGet Pack targets and so we have to use the private/generic names here. --> |
188 | 164 | <PropertyGroup Label="Source control label assignment" Condition="'$(ContainerGenerateLabels)' == 'true' and '$(PublishRepositoryUrl)' == 'true'">
|
189 | 165 | <!-- Sourcelink gives us the .git suffix, but scanning tools aren't looking for that so we trim it off here. -->
|
190 | 166 | <_TrimmedRepositoryUrl Condition="'$(RepositoryType)' == 'git' and '$(PrivateRepositoryUrl)' != '' and $(PrivateRepositoryUrl.EndsWith('.git'))">$(PrivateRepositoryUrl.Substring(0, $(PrivateRepositoryUrl.LastIndexOf('.git'))))</_TrimmedRepositoryUrl>
|
|
204 | 180 | </PublishContainerDependsOn>
|
205 | 181 | </PropertyGroup>
|
206 | 182 |
|
| 183 | + <!-- These args are relevant to container execution and are per-RID by nature. Therefore they're a direct dependency of the _PublishSingleContainer |
| 184 | + target and not computed at the outer layer. --> |
| 185 | + <Target Name="_ComputeContainerExecutionArgs"> |
| 186 | + <PropertyGroup> |
| 187 | + <!-- 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. |
| 188 | + 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. --> |
| 189 | + <_ContainerIsTargetingWindows>false</_ContainerIsTargetingWindows> |
| 190 | + <_ContainerIsTargetingWindows Condition="$(ContainerRuntimeIdentifier.StartsWith('win'))">true</_ContainerIsTargetingWindows> |
| 191 | + |
| 192 | + <!-- Set the WorkingDirectory depending on the RID --> |
| 193 | + <ContainerWorkingDirectory Condition="'$(ContainerWorkingDirectory)' == '' and !$(_ContainerIsTargetingWindows)">/app/</ContainerWorkingDirectory> |
| 194 | + <ContainerWorkingDirectory Condition="'$(ContainerWorkingDirectory)' == '' and $(_ContainerIsTargetingWindows)">C:\app\</ContainerWorkingDirectory> |
| 195 | + |
| 196 | + <_ContainerIsUsingMicrosoftDefaultImages Condition="'$(ContainerBaseImage)' == ''">true</_ContainerIsUsingMicrosoftDefaultImages> |
| 197 | + <_ContainerIsUsingMicrosoftDefaultImages Condition="'$(ContainerBaseImage)' != ''">false</_ContainerIsUsingMicrosoftDefaultImages> |
| 198 | + </PropertyGroup> |
| 199 | + |
| 200 | + <!-- 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 --> |
| 201 | + <PropertyGroup Label="ContainerUser Assignment" Condition="$(_ContainerIsUsingMicrosoftDefaultImages) and $(_ContainerIsTargetingNet8TFM) and '$(ContainerUser)' == ''"> |
| 202 | + <ContainerUser Condition="$(_ContainerIsTargetingWindows)">ContainerUser</ContainerUser> |
| 203 | + </PropertyGroup> |
| 204 | + |
| 205 | + <ItemGroup Label="AppCommand Assignment" Condition="'$(ContainerAppCommandInstruction)' != 'None'"> |
| 206 | + <!-- For self-contained, invoke the native executable as a single arg --> |
| 207 | + <ContainerAppCommand Condition="@(ContainerAppCommand->Count()) == 0 and $(_ContainerIsSelfContained)" Include="$(ContainerWorkingDirectory)$(AssemblyName)$(_NativeExecutableExtension)" /> |
| 208 | + <!-- For non self-contained, invoke `dotnet` `app.dll` as separate args --> |
| 209 | + <ContainerAppCommand Condition="@(ContainerAppCommand->Count()) == 0 and !$(_ContainerIsSelfContained)" Include="dotnet;$(ContainerWorkingDirectory)$(TargetFileName)" /> |
| 210 | + </ItemGroup> |
| 211 | + </Target> |
| 212 | + |
207 | 213 | <Target Name="_CheckContainersPackage" AfterTargets="Build">
|
208 | 214 | <PropertyGroup>
|
209 | 215 | <!-- facts to base on comparisons on -->
|
|
317 | 323 | ContainerRegistry=$(ContainerRegistry);
|
318 | 324 | _ContainerImageTags=@(ContainerImageTags, ';');
|
319 | 325 | ContainerRepository=$(ContainerRepository);
|
320 |
| - ContainerWorkingDirectory=$(ContainerWorkingDirectory); |
321 |
| - _ContainerEntrypoint=@(ContainerEntrypoint, ';'); |
322 |
| - _ContainerEntrypointArgs=@(ContainerEntrypointArgs, ';'); |
323 |
| - _ContainerAppCommand=@(ContainerAppCommand, ';'); |
324 |
| - _ContainerAppCommandArgs=@(ContainerAppCommandArgs, ';'); |
325 |
| - ContainerAppCommandInstruction=$(ContainerAppCommandInstruction); |
326 |
| - _ContainerDefaultArgs=@(ContainerDefaultArgs, ';'); |
327 | 326 | _ContainerLabel=@(ContainerLabel->'%(Identity):%(Value)');
|
328 | 327 | _ContainerPort=@(ContainerPort->'%(Identity):%(Type)');
|
329 | 328 | _ContainerEnvironmentVariables=@(ContainerEnvironmentVariable->'%(Identity):%(Value)');
|
330 |
| - ContainerUser=$(ContainerUser); |
331 | 329 | ContainerGenerateLabels=$(ContainerGenerateLabels);
|
332 | 330 | ContainerGenerateLabelsImageBaseDigest=$(ContainerGenerateLabelsImageBaseDigest)
|
333 | 331 | "/>
|
|
359 | 357 | <ItemGroup>
|
360 | 358 | <OriginalImageTags Include="$(_ContainerImageTags)"/>
|
361 | 359 | <ContainerImageTags Include="@(OriginalImageTags->'%(Identity)-$(ContainerRuntimeIdentifier)')" />
|
362 |
| - <ContainerEntrypoint Include="$(_ContainerEntrypoint)"/> |
363 |
| - <ContainerEntrypointArgs Include="$(_ContainerEntrypointArgs)"/> |
364 |
| - <ContainerAppCommand Include="$(_ContainerAppCommand)"/> |
365 |
| - <ContainerAppCommandArgs Include="$(_ContainerAppCommandArgs)"/> |
366 |
| - <ContainerDefaultArgs Include="$(_ContainerDefaultArgs)"/> |
367 | 360 |
|
368 | 361 | <_ParsedContainerLabel
|
369 | 362 | Condition="'$(_ContainerLabel)' != ':'"
|
|
417 | 410 |
|
418 | 411 | <Error Condition="'$(_IsMultiTFMBuild)' == 'true'" Code="CONTAINERS0666" Text="Containers cannot be published for multiple TargetFrameworks at this time. Please specify a TargetFramework." />
|
419 | 412 | </Target>
|
420 |
| - |
421 | 413 | </Project>
|
0 commit comments