diff --git a/msbuild/Xamarin.MacDev.Tasks/Tasks/SymbolStrip.cs b/msbuild/Xamarin.MacDev.Tasks/Tasks/SymbolStrip.cs index 759d98fb812..7b7db8de10f 100644 --- a/msbuild/Xamarin.MacDev.Tasks/Tasks/SymbolStrip.cs +++ b/msbuild/Xamarin.MacDev.Tasks/Tasks/SymbolStrip.cs @@ -23,6 +23,10 @@ public class SymbolStrip : XamarinParallelTask, ITaskCallback { // This can also be specified as metadata on the Executable item (as 'SymbolFile') public string SymbolFile { get; set; } = string.Empty; + // The local path to the symbol file (used to transfer it to the remote Mac). + // This can also be specified as metadata on the Executable item (as 'SymbolFileLocalPath') + public string SymbolFileLocalPath { get; set; } = string.Empty; + // This can also be specified as metadata on the Executable item (as 'Kind') public string Kind { get; set; } = string.Empty; #endregion @@ -78,6 +82,16 @@ public override bool Execute () public bool ShouldCreateOutputFile (ITaskItem item) => false; - public IEnumerable GetAdditionalItemsToBeCopied () => Enumerable.Empty (); + public IEnumerable GetAdditionalItemsToBeCopied () + { + if (!string.IsNullOrEmpty (SymbolFileLocalPath)) + yield return new Microsoft.Build.Utilities.TaskItem (SymbolFileLocalPath); + + foreach (var item in Executable) { + var symbolFileLocalPath = item.GetMetadata ("SymbolFileLocalPath"); + if (!string.IsNullOrEmpty (symbolFileLocalPath)) + yield return new Microsoft.Build.Utilities.TaskItem (symbolFileLocalPath); + } + } } } diff --git a/msbuild/Xamarin.Shared/Xamarin.Shared.targets b/msbuild/Xamarin.Shared/Xamarin.Shared.targets index 5accac63eb0..4701cb4c38c 100644 --- a/msbuild/Xamarin.Shared/Xamarin.Shared.targets +++ b/msbuild/Xamarin.Shared/Xamarin.Shared.targets @@ -3029,7 +3029,8 @@ Copyright (C) 2018 Microsoft. All rights reserved. %(Filename).dSYM <_PostProcessingItem Include="$([System.IO.Path]::GetFileName('$(AppBundleDir)'))/$(_NativeExecutableRelativePath)" Condition="'$(IsWatchApp)' != 'true'"> - $(_SymbolsListFullPath) + $(_SymbolsListFullPath) + $(_MtouchSymbolsList) $(_AppBundleName)$(AppBundleExtension).dSYM $(IsXpcService) $(IsAppExtension) @@ -3201,6 +3202,7 @@ Copyright (C) 2018 Microsoft. All rights reserved. MaxDegreeOfParallelism="$(SymbolStripMaxDegreeOfParallelism)" StripPath="$(StripPath)" SymbolFile="%(_NativeStripItems.SymbolFile)" + SymbolFileLocalPath="%(_NativeStripItems.SymbolFileLocalPath)" /> diff --git a/tests/dotnet/UnitTests/ProjectTest.cs b/tests/dotnet/UnitTests/ProjectTest.cs index 64d3af42e5d..1e27e914109 100644 --- a/tests/dotnet/UnitTests/ProjectTest.cs +++ b/tests/dotnet/UnitTests/ProjectTest.cs @@ -2811,6 +2811,29 @@ public void StrippedRuntimeIdentifiers (ApplePlatform platform, string runtimeId Assert.That (symbols, Does.Contain ("_xamarin_release_managed_ref"), "_xamarin_release_managed_ref"); } + [Test] + [TestCase (ApplePlatform.MacOSX, "osx-arm64;osx-x64")] + [TestCase (ApplePlatform.MacCatalyst, "maccatalyst-x64;")] + public void StrippedWithExportSymbolsExplicitlyFalse (ApplePlatform platform, string runtimeIdentifiers) + { + var project = "MySimpleApp"; + Configuration.IgnoreIfIgnoredPlatform (platform); + Configuration.AssertRuntimeIdentifiersAvailable (platform, runtimeIdentifiers); + + var project_path = GetProjectPath (project, runtimeIdentifiers: runtimeIdentifiers, platform: platform, out var appPath); + Clean (project_path); + var properties = GetDefaultProperties (runtimeIdentifiers); + properties ["NoSymbolStrip"] = "false"; + properties ["_ExportSymbolsExplicitly"] = "false"; + DotNet.AssertBuild (project_path, properties); + + var appExecutable = GetNativeExecutable (platform, appPath); + ExecuteWithMagicWordAndAssert (platform, runtimeIdentifiers, appExecutable); + + var symbols = Configuration.GetNativeSymbols (appExecutable); + Assert.That (symbols, Does.Contain ("_xamarin_release_managed_ref"), "_xamarin_release_managed_ref"); + } + [Test] [TestCase (ApplePlatform.iOS, "ios-arm64;", "iOS")] [TestCase (ApplePlatform.MacOSX, "osx-arm64;osx-x64", "macOS")]