Skip to content

Commit e7fae7b

Browse files
committed
[msbuild] Don't override GetTargetPath/Build/Rebuild for app extensions. Fixes #23516.
Don't override the GetTargetPath/Build/Rebuild targets for app extensions, because we also override some of these targets when building remotely, and the custom logic for app extensions is overridden. Instead create new targets that depend on those we previously overrode instead. Fixes #23516.
1 parent 6aa3e82 commit e7fae7b

File tree

6 files changed

+22
-25
lines changed

6 files changed

+22
-25
lines changed

msbuild/Xamarin.Shared/Xamarin.Mac.AppExtension.Common.targets

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,6 @@ Copyright (C) 2013-2014 Xamarin. All rights reserved.
2525

2626
<Import Project="$(MSBuildThisFileDirectory)$(MSBuildThisFileName).Before.targets"
2727
Condition="Exists('$(MSBuildThisFileDirectory)$(MSBuildThisFileName).Before.targets')"/>
28-
29-
<!-- Override GetTargetPath, Build, and Rebuild -->
30-
<Target Name="GetBundleTargetPath" DependsOnTargets="_GenerateBundleName;$(GetTargetPathDependsOn)" Outputs="@(_AppExtensionBundlePath)" />
31-
<Target Name="Build" Condition="'$(_InvalidConfigurationWarning)' != 'true'" DependsOnTargets="_EnabledLocalSigning;_GenerateBundleName;$(BuildDependsOn)" Outputs="$(_AppExtensionBundlePath)" />
32-
<Target Name="Rebuild" Condition="'$(_InvalidConfigurationWarning)' != 'true'" DependsOnTargets="_EnabledLocalSigning;_GenerateBundleName;$(RebuildDependsOn)" Outputs="$(_AppExtensionBundlePath)" />
33-
34-
<Target Name="_EnabledLocalSigning" DependsOnTargets="_DetectSigningIdentity">
35-
<PropertyGroup>
36-
<CodesignEntitlements Condition="'$(CodesignEntitlements)' == ''">Entitlements.plist</CodesignEntitlements>
37-
</PropertyGroup>
38-
</Target>
3928

4029
<Target Name="CreateIpa"/>
4130

msbuild/Xamarin.Shared/Xamarin.Shared.targets

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2665,6 +2665,10 @@ Copyright (C) 2018 Microsoft. All rights reserved.
26652665

26662666
<!-- App extensions -->
26672667

2668+
<Target Name="GetAppExtensionBundlePath" DependsOnTargets="_GenerateBundleName;$(GetTargetPathDependsOn)" Outputs="@(_AppExtensionBundlePath)" />
2669+
2670+
<Target Name="BuildAndGetAppExtensionBundlePath" DependsOnTargets="Build" Outputs="@(_AppExtensionBundlePath)" />
2671+
26682672
<Target Name="_AssignAppExtensionConfiguration" Condition="'@(_AppExtensionReference)' != ''">
26692673
<!-- assign configs if building a solution file -->
26702674
<AssignProjectConfiguration
@@ -2712,10 +2716,10 @@ Copyright (C) 2018 Microsoft. All rights reserved.
27122716
<_BuildReferencedExtensionProjects Condition="'$(BuildingInsideVisualStudio)' != 'true'">true</_BuildReferencedExtensionProjects>
27132717
</PropertyGroup>
27142718

2715-
<!-- If the referenced projects have already been built, then just get the target paths -->
2719+
<!-- If the referenced projects have already been built, then just get the app extensions' bundle paths -->
27162720
<MSBuild
27172721
Projects="@(_AppExtensionReferenceWithConfigurationExistent)"
2718-
Targets="GetBundleTargetPath"
2722+
Targets="GetAppExtensionBundlePath"
27192723
Properties="%(_AppExtensionReferenceWithConfigurationExistent.SetConfiguration); %(_AppExtensionReferenceWithConfigurationExistent.SetPlatform)"
27202724
Condition="'@(_AppExtensionReferenceWithConfigurationExistent)' != '' and '$(_BuildReferencedExtensionProjects)' != 'true'">
27212725

@@ -2725,6 +2729,7 @@ Copyright (C) 2018 Microsoft. All rights reserved.
27252729
<!-- Build the referenced project if required -->
27262730
<MSBuild
27272731
Projects="@(_AppExtensionReferenceWithConfigurationExistent)"
2732+
Targets="BuildAndGetAppExtensionBundlePath"
27282733
Properties="%(_AppExtensionReferenceWithConfigurationExistent.SetConfiguration); %(_AppExtensionReferenceWithConfigurationExistent.SetPlatform)"
27292734
Condition="'@(_AppExtensionReferenceWithConfigurationExistent)' != '' and '$(_BuildReferencedExtensionProjects)' == 'true' ">
27302735

msbuild/Xamarin.Shared/Xamarin.TVOS.AppExtension.Common.targets

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@ Copyright (C) 2014-2016 Xamarin. All rights reserved.
3333
<Import Project="$(MSBuildThisFileDirectory)$(MSBuildThisFileName).Before.targets"
3434
Condition="Exists('$(MSBuildThisFileDirectory)$(MSBuildThisFileName).Before.targets')"/>
3535

36-
<!-- Override GetTargetPath, Build, and Rebuild -->
37-
<Target Name="GetBundleTargetPath" DependsOnTargets="_GenerateBundleName;$(GetTargetPathDependsOn)" Outputs="@(_AppExtensionBundlePath)" />
38-
<Target Name="Build" Condition="'$(_InvalidConfigurationWarning)' != 'true'" DependsOnTargets="_GenerateBundleName;$(BuildDependsOn)" Outputs="@(_AppExtensionBundlePath)" />
39-
<Target Name="Rebuild" Condition="'$(_InvalidConfigurationWarning)' != 'true'" DependsOnTargets="_GenerateBundleName;$(RebuildDependsOn)" Outputs="@(_AppExtensionBundlePath)" />
40-
4136
<Import Project="$(MSBuildThisFileDirectory)$(MSBuildThisFileName).After.targets"
4237
Condition="Exists('$(MSBuildThisFileDirectory)$(MSBuildThisFileName).After.targets')"/>
4338

msbuild/Xamarin.Shared/Xamarin.iOS.AppExtension.Common.targets

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@ Copyright (C) 2014-2016 Xamarin. All rights reserved.
2626

2727
<Import Project="$(MSBuildThisFileDirectory)$(MSBuildThisFileName).Before.targets"
2828
Condition="Exists('$(MSBuildThisFileDirectory)$(MSBuildThisFileName).Before.targets')"/>
29-
30-
<!-- Override GetTargetPath, Build, and Rebuild -->
31-
<Target Name="GetBundleTargetPath" DependsOnTargets="_GenerateBundleName;$(GetTargetPathDependsOn)" Outputs="@(_AppExtensionBundlePath)" />
32-
<Target Name="Build" Condition="'$(_InvalidConfigurationWarning)' != 'true'" DependsOnTargets="_GenerateBundleName;$(BuildDependsOn)" Outputs="@(_AppExtensionBundlePath)" />
33-
<Target Name="Rebuild" Condition="'$(_InvalidConfigurationWarning)' != 'true'" DependsOnTargets="_GenerateBundleName;$(RebuildDependsOn)" Outputs="@(_AppExtensionBundlePath)" />
3429

3530
<Import Project="$(MSBuildThisFileDirectory)$(MSBuildThisFileName).After.targets"
3631
Condition="Exists('$(MSBuildThisFileDirectory)$(MSBuildThisFileName).After.targets')"/>

msbuild/Xamarin.Shared/Xamarin.iOS.Common.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ Copyright (C) 2013-2016 Xamarin. All rights reserved.
235235
<!-- If the referenced projects have already been built, then just get the target paths -->
236236
<MSBuild
237237
Projects="@(_WatchAppReferenceWithConfigurationExistent)"
238-
Targets="GetBundleTargetPath"
238+
Targets="GetAppExtensionBundlePath"
239239
Properties="%(_WatchAppReferenceWithConfigurationExistent.SetConfiguration); %(_WatchAppReferenceWithConfigurationExistent.SetPlatform)"
240240
Condition="'@(_WatchAppReferenceWithConfigurationExistent)' != '' and '$(_BuildReferencedExtensionProjects)' != 'true'">
241241

tests/dotnet/UnitTests/ProjectTest.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1868,6 +1868,19 @@ public void KillEverything ()
18681868
[TestCase (ApplePlatform.MacOSX, "osx-x64;osx-arm64", true)]
18691869
// [TestCase ("MacCatalyst", "")] - No extension support yet
18701870
public void BuildProjectsWithExtensions (ApplePlatform platform, string runtimeIdentifier, bool isNativeAot)
1871+
{
1872+
BuildProjectsWithExtensionsImpl (platform, runtimeIdentifier, isNativeAot);
1873+
}
1874+
1875+
[TestCase (ApplePlatform.iOS, "ios-arm64", false)]
1876+
[Category ("RemoteWindows")]
1877+
public void BuildProjectsWithExtensionsOnRemoteWindows (ApplePlatform platform, string runtimeIdentifier, bool isNativeAot)
1878+
{
1879+
Configuration.IgnoreIfNotOnWindows ();
1880+
BuildProjectsWithExtensionsImpl (platform, runtimeIdentifier, isNativeAot, AddRemoteProperties ());
1881+
}
1882+
1883+
void BuildProjectsWithExtensionsImpl (ApplePlatform platform, string runtimeIdentifier, bool isNativeAot, Dictionary<string, string>? properties = null)
18711884
{
18721885
Configuration.IgnoreIfIgnoredPlatform (platform);
18731886
var consumingProjectDir = GetProjectPath ("ExtensionConsumer", runtimeIdentifier, platform, out var appPath);
@@ -1876,7 +1889,7 @@ public void BuildProjectsWithExtensions (ApplePlatform platform, string runtimeI
18761889
Clean (extensionProjectDir);
18771890
Clean (consumingProjectDir);
18781891

1879-
var properties = GetDefaultProperties (runtimeIdentifier);
1892+
properties = GetDefaultProperties (runtimeIdentifier, extraProperties: properties);
18801893

18811894
if (isNativeAot) {
18821895
properties ["PublishAot"] = "true";

0 commit comments

Comments
 (0)