Skip to content

Commit 6abcc15

Browse files
authored
fix ordering so that getting Container config establishes RIDness (#49590)
1 parent aac62da commit 6abcc15

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

src/Containers/packaging/build/Microsoft.NET.Build.Containers.targets

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171

7272
<!-- This Target is called early on in the chain for both single-RID and multi-RID containers - but for single-RID it's important
7373
that we ensure all of the data necessary to create a single-RID container is computed after we exit this target. -->
74-
<Target Name="ComputeContainerConfig" DependsOnTargets="ComputeContainerBaseImage;_ComputeContainerExecutionArgs">
74+
<Target Name="ComputeContainerConfig" DependsOnTargets="ComputeContainerBaseImage;_ContainerEstablishRIDNess;_ComputeContainerExecutionArgs">
7575
<PropertyGroup Label="VS defaults">
7676
<!-- RegistryUrl is used by existing VS targets for Docker builds - this lets us fill that void -->
7777
<ContainerRegistry Condition="'$(RegistryUrl)' != ''">$(RegistryUrl)</ContainerRegistry>
@@ -181,21 +181,20 @@
181181
<PropertyGroup>
182182
<PublishContainerDependsOn>
183183
_ContainerVerifySDKVersion;
184-
_ContainerEstablishRIDNess;
185184
ComputeContainerConfig;
186-
_CheckContainersPackage
185+
_CheckContainersPackage;
187186
</PublishContainerDependsOn>
188187
</PropertyGroup>
189188

190189
<!-- These args are relevant to container execution and are per-RID by nature. Therefore they're a direct dependency of the _PublishSingleContainer
191190
target and not computed at the outer, multi-RID build layer. -->
192-
<Target Name="_ComputeContainerExecutionArgs" Condition="'$(_IsSingleRIDBuild)' == 'true'">
191+
<Target Name="_ComputeContainerExecutionArgs" DependsOnTargets="_ContainerEstablishRIDNess" Condition="'$(_IsSingleRIDBuild)' == 'true'">
193192
<PropertyGroup>
194193
<!-- 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.
195194
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. -->
196195
<_ContainerIsTargetingWindows>false</_ContainerIsTargetingWindows>
197196
<_ContainerIsTargetingWindows Condition="$(ContainerRuntimeIdentifier.StartsWith('win'))">true</_ContainerIsTargetingWindows>
198-
197+
199198
<!-- Set the WorkingDirectory depending on the RID -->
200199
<ContainerWorkingDirectory Condition="'$(ContainerWorkingDirectory)' == '' and !$(_ContainerIsTargetingWindows)">/app/</ContainerWorkingDirectory>
201200
<ContainerWorkingDirectory Condition="'$(ContainerWorkingDirectory)' == '' and $(_ContainerIsTargetingWindows)">C:\app\</ContainerWorkingDirectory>

test/Microsoft.NET.Build.Containers.IntegrationTests/TargetsTests.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ public void CanDeferContainerAppCommand(
2222
{
2323
[prop] = value.ToString(),
2424
[ContainerRuntimeIdentifier] = $"{os}-x64",
25-
["_IsSingleRIDBuild"] = "true",
2625

2726
}, projectName: $"{nameof(CanDeferContainerAppCommand)}_{prop}_{value}_{string.Join("_", expectedAppCommandArgs)}");
2827
using var _ = d;
@@ -312,7 +311,6 @@ public void CanComputeContainerUser(string tfm, string rid, string? expectedUser
312311
["TargetFrameworkVersion"] = tfm,
313312
["TargetFramework"] = "net" + tfm.TrimStart('v'),
314313
["ContainerRuntimeIdentifier"] = rid,
315-
["_IsSingleRIDBuild"] = "true",
316314
}, projectName: $"{nameof(CanComputeContainerUser)}_{tfm}_{rid}_{expectedUser}");
317315
using var _ = d;
318316
var instance = project.CreateProjectInstance(ProjectInstanceSettings.None);

0 commit comments

Comments
 (0)