Skip to content

Commit 576858c

Browse files
RedthCopilot
andcommitted
Harden application artifact extension ordering
Make Build a mandatory GetApplicationArtifacts dependency instead of part of the overridable GetApplicationArtifactsDependsOn property. Extension targets still run after platform artifacts are produced, and tests now overwrite the property to prove Build cannot be removed while metadata augmentation still applies to GetApplicationArtifacts and Publish. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 390b162 commit 576858c

4 files changed

Lines changed: 9 additions & 11 deletions

File tree

docs/building-apps/build-properties.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,8 @@ Where the generated source from the generator are saved.
545545

546546
A semi-colon delimited property that can be used to extend the
547547
[GetApplicationArtifacts](build-targets.md#getapplicationartifacts) and
548-
`Publish` targets. MSBuild targets added to this property will execute after
548+
`Publish` targets. The platform build is a mandatory dependency of
549+
`GetApplicationArtifacts`; MSBuild targets added to this property execute after
549550
the platform build has collected `@(ApplicationArtifact)` items and before
550551
`GetApplicationArtifacts` or `Publish` returns them.
551552

docs/building-apps/build-targets.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,10 @@ Added in .NET 11.
4747
## GetApplicationArtifacts
4848

4949
Builds the project and returns the `@(ApplicationArtifact)` item group. This
50-
target can be used by custom build scripts to query final `.app`, `.ipa`,
51-
`.pkg`, and `.xcarchive` artifacts. The `Publish` target returns the same item
52-
group for artifacts it creates.
50+
target always runs the platform build first so `.app`, `.ipa`, `.pkg`, and
51+
`.xcarchive` artifacts are populated before any custom metadata extension
52+
targets run. The `Publish` target returns the same item group for artifacts it
53+
creates.
5354

5455
```shell
5556
$ dotnet build -t:GetApplicationArtifacts

msbuild/Xamarin.Shared/Xamarin.Shared.targets

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3429,17 +3429,13 @@ Copyright (C) 2018 Microsoft. All rights reserved.
34293429
_ZipIpa
34303430
</CreateIpaDependsOn>
34313431

3432-
<GetApplicationArtifactsDependsOn>
3433-
Build;
3434-
$(GetApplicationArtifactsDependsOn)
3435-
</GetApplicationArtifactsDependsOn>
34363432
</PropertyGroup>
34373433

34383434
<Target Name="_BeforeCreateIpaForDistribution" Condition="'$(IsAppDistribution)' == 'true'" DependsOnTargets="$(_BeforeCreateIpaForDistributionDependsOn)" />
34393435

34403436
<Target Name="CreateIpa" Condition="'$(_CanArchive)' == 'true' And '$(SdkIsDesktop)' != 'true'" DependsOnTargets="$(CreateIpaDependsOn)" />
34413437

3442-
<Target Name="GetApplicationArtifacts" DependsOnTargets="$(GetApplicationArtifactsDependsOn)" Returns="@(ApplicationArtifact)" />
3438+
<Target Name="GetApplicationArtifacts" DependsOnTargets="Build;$(GetApplicationArtifactsDependsOn)" Returns="@(ApplicationArtifact)" />
34433439

34443440
<Import Project="$(MSBuildThisFileDirectory)Xamarin.Shared.ObjCBinding.targets" Condition="'$(IsBindingProject)' == 'true'" />
34453441

tests/dotnet/UnitTests/PostBuildTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public void GetApplicationArtifactsDependsOnTest (ApplePlatform platform, string
117117
var existingProjectContent = File.ReadAllText (project_path);
118118
var newProjectContent = existingProjectContent.Replace ("</Project>", @"
119119
<PropertyGroup>
120-
<GetApplicationArtifactsDependsOn>$(GetApplicationArtifactsDependsOn);AddMauiApplicationArtifactMetadata</GetApplicationArtifactsDependsOn>
120+
<GetApplicationArtifactsDependsOn>AddMauiApplicationArtifactMetadata</GetApplicationArtifactsDependsOn>
121121
</PropertyGroup>
122122
<Target Name=""AddMauiApplicationArtifactMetadata"">
123123
<ItemGroup>
@@ -325,7 +325,7 @@ public void PublishApplicationArtifactsDependsOnTest (ApplePlatform platform, st
325325
var existingProjectContent = File.ReadAllText (project_path);
326326
var newProjectContent = existingProjectContent.Replace ("</Project>", @"
327327
<PropertyGroup>
328-
<GetApplicationArtifactsDependsOn>$(GetApplicationArtifactsDependsOn);AddMauiPublishApplicationArtifactMetadata</GetApplicationArtifactsDependsOn>
328+
<GetApplicationArtifactsDependsOn>AddMauiPublishApplicationArtifactMetadata</GetApplicationArtifactsDependsOn>
329329
</PropertyGroup>
330330
<Target Name=""AddMauiPublishApplicationArtifactMetadata"">
331331
<ItemGroup>

0 commit comments

Comments
 (0)