From 62bc02760a55777612555154930d78d4bdba54b7 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Wed, 7 Sep 2022 11:33:39 +0200 Subject: [PATCH] [msbuild] Compute _AppContainerDir from AppBundleDir if AppBundleDir is set by the developer. Fixes #15014. (#15869) Fixes https://github.com/xamarin/xamarin-macios/issues/15014. --- msbuild/Xamarin.Shared/Xamarin.Shared.targets | 3 +++ tests/dotnet/UnitTests/ProjectTest.cs | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/msbuild/Xamarin.Shared/Xamarin.Shared.targets b/msbuild/Xamarin.Shared/Xamarin.Shared.targets index 7a0f966006..10766d6575 100644 --- a/msbuild/Xamarin.Shared/Xamarin.Shared.targets +++ b/msbuild/Xamarin.Shared/Xamarin.Shared.targets @@ -2684,6 +2684,9 @@ Copyright (C) 2018 Microsoft. All rights reserved. <_AppContainerDir Condition="'$(IsAppDistribution)' == 'true'">$(ArchivePath)\Products\Applications\ $(_AppContainerDir)$(_AppBundleName)$(AppBundleExtension) + + <_AppContainerDir>$([System.IO.Path]::GetDirectoryName($(AppBundleDir)))/ + <_AppBundlePath>$(AppBundleDir) diff --git a/tests/dotnet/UnitTests/ProjectTest.cs b/tests/dotnet/UnitTests/ProjectTest.cs index 9c89268c7c..cafccb063c 100644 --- a/tests/dotnet/UnitTests/ProjectTest.cs +++ b/tests/dotnet/UnitTests/ProjectTest.cs @@ -982,5 +982,19 @@ namespace Xamarin.Tests { Assert.That (errors [0].Message, Does.Contain ("Error loading Entitlements.plist template 'Entitlements.plist'"), "Message"); } } + + [TestCase (ApplePlatform.MacOSX, "osx-arm64")] + public void CustomAppBundleDir (ApplePlatform platform, string runtimeIdentifiers) + { + var project = "MySimpleApp"; + Configuration.IgnoreIfIgnoredPlatform (platform); + + var project_path = GetProjectPath (project, runtimeIdentifiers: runtimeIdentifiers, platform: platform, out var appPath); + Clean (project_path); + var properties = GetDefaultProperties (runtimeIdentifiers); + var customAppBundleDir = Path.Combine (Cache.CreateTemporaryDirectory (), project + ".app"); + properties ["AppBundleDir"] = customAppBundleDir; + var result = DotNet.AssertBuild (project_path, properties); + } } }