Skip to content
Draft
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
11 changes: 11 additions & 0 deletions docs/building-apps/build-properties.md
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,17 @@ This also applies to how native references are stored inside NuGets.
> [!NOTE]
> In some cases it can be beneficial to force a zip file on iOS as well, especially when there's a framework with files that have long names, because the zip file can sometimes work around MAX_PATH issues on Windows.

## CopyDSYMToPublishDirectory

A boolean property that specifies whether any generated `*.dSYM` directories should be
copied to the publish directory when publishing (`dotnet publish`).

The `*.dSYM` directories are generated next to the app bundle (see [NoDSymUtil](#nodsymutil)),
and when this property is `true` they'll also be copied to the publish directory (next to the
generated `.ipa`/`.pkg`).

The default value is `true`.

## CopySceneKitAssetsPath

The full path to the `copySceneKitAssets` tool.
Expand Down
29 changes: 28 additions & 1 deletion dotnet/targets/Xamarin.Shared.Sdk.Publish.targets
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,35 @@
Condition="$(RuntimeIdentifiers.Contains('iossimulator-')) Or $(RuntimeIdentifiers.Contains('tvossimulator-'))"
/>
</Target>
<Target Name="Publish" DependsOnTargets="_PrePublish;GetApplicationArtifacts" Returns="@(ApplicationArtifact)">
<Target Name="Publish" DependsOnTargets="_PrePublish;GetApplicationArtifacts;_CopyDSymToPublishDirectory" Returns="@(ApplicationArtifact)">
<Message Importance="high" Text="Created the package: $(IpaPackagePath)" Condition="'$(BuildIpa)' == 'true' And '$(SdkIsMobile)' == 'true'" />
<Message Importance="high" Text="Created the package: $(PkgPackagePath)" Condition="'$(CreatePackage)' == 'true' And '$(SdkIsDesktop)' == 'true'" />
</Target>

<!--
Copy any generated *.dSYM directories (which are created next to the app bundle) to the
publish directory, so that the debug symbols end up alongside the published .ipa/.pkg.
This can be disabled by setting CopyDSYMToPublishDirectory=false.
Ref: https://github.com/dotnet/macios/issues/15384
-->
<Target Name="_CopyDSymToPublishDirectory"
Condition="'$(CopyDSYMToPublishDirectory)' != 'false' And '$(_CanOutputAppBundle)' == 'true' And $([MSBuild]::IsOSPlatform('osx'))"
DependsOnTargets="_GenerateBundleName">
<GetDirectories SessionId="$(BuildSessionId)" Path="$(_AppContainerDir)" Pattern="*.dSYM">
<Output TaskParameter="Directories" ItemName="_DSymDirToPublish" />
</GetDirectories>
<ItemGroup>
<_DSymFileToPublish Include="%(_DSymDirToPublish.Identity)/**/*">
<DSymDirName>%(_DSymDirToPublish.Filename)%(_DSymDirToPublish.Extension)</DSymDirName>
</_DSymFileToPublish>
</ItemGroup>
<Copy
SessionId="$(BuildSessionId)"
Condition="'@(_DSymFileToPublish->Count())' != '0'"
SourceFiles="@(_DSymFileToPublish)"
DestinationFiles="@(_DSymFileToPublish -> '$(PublishDir)%(DSymDirName)/%(RecursiveDir)%(Filename)%(Extension)')"
SkipUnchangedFiles="true">
<Output TaskParameter="DestinationFiles" ItemName="FileWrites" />
</Copy>
</Target>
</Project>
40 changes: 40 additions & 0 deletions tests/dotnet/UnitTests/PostBuildTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,46 @@ public void StaticFrameworksNotInPostProcessing (ApplePlatform platform, string
Assert.That (staticFrameworkItems, Is.Empty, $"Static framework XStaticArTest should not be in post-processing items. All items:\n\t{string.Join ("\n\t", postProcessingItems.Select (i => i.ItemSpec))}");
}

[Test]
[TestCase (ApplePlatform.iOS, "ios-arm64", true)]
[TestCase (ApplePlatform.iOS, "ios-arm64", false)]
public void PublishDSymToPublishDirectory (ApplePlatform platform, string runtimeIdentifiers, bool copyDSym)
{
// https://github.com/dotnet/macios/issues/15384
// When publishing, the generated *.dSYM directories should be copied to the publish
// directory (unless CopyDSYMToPublishDirectory=false).
var project = "MySimpleApp";
var configuration = "Release";
Configuration.IgnoreIfIgnoredPlatform (platform);
Configuration.AssertRuntimeIdentifiersAvailable (platform, runtimeIdentifiers);

var project_path = GetProjectPath (project, runtimeIdentifiers, platform: platform, out var appPath, configuration: configuration);
Clean (project_path);

var properties = GetDefaultProperties (runtimeIdentifiers);
properties ["Configuration"] = configuration;
if (!copyDSym)
properties ["CopyDSYMToPublishDirectory"] = "false";

DotNet.AssertPublish (project_path, properties);

var appContainerDir = Path.GetDirectoryName (appPath)!;
var appBundleName = Path.GetFileName (appPath);
var publishDir = Path.Combine (appContainerDir, "publish");

// The dSYM must have been generated next to the app bundle in the first place.
var sourceDSym = Path.Combine (appContainerDir, appBundleName + ".dSYM");
Assert.That (sourceDSym, Does.Exist, "Source dSYM");

var publishedDSym = Path.Combine (publishDir, appBundleName + ".dSYM");
if (copyDSym) {
Assert.That (publishedDSym, Does.Exist, "Published dSYM");
Assert.That (Path.Combine (publishedDSym, "Contents", "Info.plist"), Does.Exist, "Published dSYM Info.plist");
} else {
Assert.That (publishedDSym, Does.Not.Exist, "Published dSYM (disabled)");
}
}

static ITaskItem AssertApplicationArtifact (string binLogPath, string path, ApplePlatform platform, string packageFormat, bool isDirectory)
{
var outputs = GetItems (binLogPath, "ApplicationArtifact");
Expand Down
Loading