Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions msbuild/Xamarin.Shared/Xamarin.Shared.targets
Original file line number Diff line number Diff line change
Expand Up @@ -2864,7 +2864,7 @@ Copyright (C) 2018 Microsoft. All rights reserved.
Properties="%(_AppExtensionReferenceWithConfigurationExistent.SetConfiguration); %(_AppExtensionReferenceWithConfigurationExistent.SetPlatform)"
Condition="'@(_AppExtensionReferenceWithConfigurationExistent)' != '' and '$(_BuildReferencedExtensionProjects)' != 'true'">

<Output TaskParameter="TargetOutputs" ItemName="_ResolvedAppExtensionReferences" Condition="'%(_AppExtensionReferenceWithConfigurationExistent.ReferenceOutputAssembly)' != 'false'"/>
<Output TaskParameter="TargetOutputs" ItemName="_ResolvedAppExtensionReferences" />
</MSBuild>

<!-- Build the referenced project if required -->
Expand All @@ -2874,7 +2874,7 @@ Copyright (C) 2018 Microsoft. All rights reserved.
Properties="%(_AppExtensionReferenceWithConfigurationExistent.SetConfiguration); %(_AppExtensionReferenceWithConfigurationExistent.SetPlatform)"
Condition="'@(_AppExtensionReferenceWithConfigurationExistent)' != '' and '$(_BuildReferencedExtensionProjects)' == 'true' ">

<Output TaskParameter="TargetOutputs" ItemName="_ResolvedAppExtensionReferences" Condition="'%(_AppExtensionReferenceWithConfigurationExistent.ReferenceOutputAssembly)' != 'false'"/>
<Output TaskParameter="TargetOutputs" ItemName="_ResolvedAppExtensionReferences" />
</MSBuild>

<Warning Text="Referenced $(_PlatformName) App Extension Project %(_AppExtensionReferenceWithConfigurationNonExistent.Identity) not found, ignoring."
Expand Down
1 change: 1 addition & 0 deletions tests/dotnet/ExtensionConsumer/shared.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<ItemGroup>
<ProjectReference Include="..\..\ExtensionProject\$(_PlatformName)\ExtensionProject.csproj">
<IsAppExtension>true</IsAppExtension>
<ReferenceOutputAssembly Condition="'$(TestReferenceOutputAssembly)' != ''">$(TestReferenceOutputAssembly)</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>
</Project>
44 changes: 44 additions & 0 deletions tests/dotnet/UnitTests/ProjectTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1983,6 +1983,50 @@ public void BuildProjectsWithExtensionsOnRemoteWindows (ApplePlatform platform,
BuildProjectsWithExtensionsImpl (platform, runtimeIdentifier, isNativeAot, AddRemoteProperties ());
}

// App extensions must be embedded in the container app even when the project reference
// says ReferenceOutputAssembly=false. Ref: https://github.com/dotnet/macios/issues/26453
[TestCase (ApplePlatform.iOS, "iossimulator-x64")]
[TestCase (ApplePlatform.TVOS, "tvossimulator-x64")]
[TestCase (ApplePlatform.MacOSX, "osx-x64")]
[TestCase (ApplePlatform.MacCatalyst, "maccatalyst-arm64")]
public void BuildProjectsWithExtensionsWithoutReferenceOutputAssembly (ApplePlatform platform, string runtimeIdentifier)
{
var properties = new Dictionary<string, string> {
{ "TestReferenceOutputAssembly", "false" },
};
BuildProjectsWithExtensionsImpl (platform, runtimeIdentifier, isNativeAot: false, properties);
}
Comment thread
rolfbjarne marked this conversation as resolved.
Resolved

// Same as the previous test, but for the code path taken when the extension projects have
// already been built (which is what some versions of the IDE do). This exercises the other
// <MSBuild> invocation in the _ResolveAppExtensionReferences target.
[TestCase (ApplePlatform.iOS, "iossimulator-x64")]
[TestCase (ApplePlatform.TVOS, "tvossimulator-x64")]
[TestCase (ApplePlatform.MacOSX, "osx-x64")]
[TestCase (ApplePlatform.MacCatalyst, "maccatalyst-arm64")]
public void BuildProjectsWithPrebuiltExtensionsWithoutReferenceOutputAssembly (ApplePlatform platform, string runtimeIdentifier)
{
Configuration.IgnoreIfIgnoredPlatform (platform);

var consumingProjectDir = GetProjectPath ("ExtensionConsumer", runtimeIdentifier, platform, out var appPath);
var extensionProjectDir = GetProjectPath ("ExtensionProject", platform: platform);

Clean (extensionProjectDir);
Clean (consumingProjectDir);

// Build the extension project first, ...
DotNet.AssertBuild (extensionProjectDir, GetDefaultProperties (runtimeIdentifier));

// ... and then build the container app without building the extension project again.
var properties = GetDefaultProperties (runtimeIdentifier);
properties ["TestReferenceOutputAssembly"] = "false";
properties ["_BuildReferencedExtensionProjects"] = "false";
DotNet.AssertBuild (consumingProjectDir, properties);

var extensionPath = Path.Combine (appPath, GetPlugInsRelativePath (platform), "ExtensionProject.appex");
Assert.That (Directory.Exists (extensionPath), $"App extension directory does not exist: {extensionPath}");
}

void BuildProjectsWithExtensionsImpl (ApplePlatform platform, string runtimeIdentifier, bool isNativeAot, Dictionary<string, string>? properties = null)
{
Configuration.IgnoreIfIgnoredPlatform (platform);
Expand Down