Skip to content

Commit

Permalink
[dotnet] Copy the pdb for our platform assemblies to the app bundle. F…
Browse files Browse the repository at this point in the history
…ixes #11879. (#18970)

Copy the pdb for our platform assembly to the app bundle if we're in
Debug mode.

Fixes #11879.
  • Loading branch information
rolfbjarne committed Sep 11, 2023
1 parent a7e96e5 commit ea8ad15
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
30 changes: 29 additions & 1 deletion dotnet/targets/Xamarin.Shared.Sdk.targets
Expand Up @@ -1459,8 +1459,36 @@
</ItemGroup>
</Target>

<!-- Add the pdb for Microsoft.<platform>.dll to the app bundle if we're debugging -->
<PropertyGroup>
<BundleDebugSymbolFileForSdkAssembly Condition="'$(BundleDebugSymbolFileForSdkAssembly)' == ''">$(_BundlerDebug)</BundleDebugSymbolFileForSdkAssembly>
</PropertyGroup>
<Target Name="_AddDebugSymbolsToBundle"
DependsOnTargets="ResolveRuntimePackAssets;_ComputeFrameworkVariables"
BeforeTargets="_ResolveCopyLocalAssetsForPublish"
Condition="'$(BundleDebugSymbolFileForSdkAssembly)' == 'true'"
>
<ItemGroup>
<ReferenceCopyLocalPaths
Include="@(ReferenceCopyLocalPaths->'%(RootDir)%(Directory)%(Filename).pdb')"
Condition="'%(ReferenceCopyLocalPaths.NuGetPackageId)' == '$(_XamarinNugetPackageId)' and Exists('%(RootDir)%(Directory)%(Filename).pdb')" />
</ItemGroup>
</Target>

<PropertyGroup>
<_ComputePublishLocationDependsOn>
$(_ComputePublishLocationDependsOn);
_GenerateBundleName;
_ParseBundlerArguments;
_ComputeMonoLibraries;
_DetectSigningIdentity;
_PrepareResourceRules;
_AddDebugSymbolsToBundle;
</_ComputePublishLocationDependsOn>
</PropertyGroup>

<Target Name="_ComputePublishLocation"
DependsOnTargets="_GenerateBundleName;_ParseBundlerArguments;_ComputeMonoLibraries;_DetectSigningIdentity;_PrepareResourceRules"
DependsOnTargets="$(_ComputePublishLocationDependsOn)"
Condition="'$(_CanOutputAppBundle)' == 'true'"
>
<PropertyGroup>
Expand Down
8 changes: 4 additions & 4 deletions tests/dotnet/UnitTests/BundleStructureTest.cs
Expand Up @@ -291,7 +291,7 @@ internal static void CheckAppBundleContents (ApplePlatform platform, IEnumerable
expectedFiles.Add (Path.Combine (assemblyDirectory, "Touch.Client.dll"));
if (includeDebugFiles)
expectedFiles.Add (Path.Combine (assemblyDirectory, "Touch.Client.pdb"));
AddMultiRidAssembly (platform, expectedFiles, assemblyDirectory, Path.GetFileNameWithoutExtension (Configuration.GetBaseLibraryName (platform, true)), runtimeIdentifiers, forceSingleRid: (platform == ApplePlatform.MacCatalyst && !isReleaseBuild) || platform == ApplePlatform.MacOSX, hasPdb: false, includeDebugFiles: includeDebugFiles);
AddMultiRidAssembly (platform, expectedFiles, assemblyDirectory, Path.GetFileNameWithoutExtension (Configuration.GetBaseLibraryName (platform, true)), runtimeIdentifiers, forceSingleRid: (platform == ApplePlatform.MacCatalyst && !isReleaseBuild) || platform == ApplePlatform.MacOSX, includeDebugFiles: includeDebugFiles);
expectedFiles.Add (Path.Combine (assemblyDirectory, "runtimeconfig.bin"));

switch (platform) {
Expand Down Expand Up @@ -422,11 +422,11 @@ static bool IsValidLoadLibrary (string library)
}


static void AddMultiRidAssembly (ApplePlatform platform, List<string> expectedFiles, string assemblyDirectory, string assemblyName, string [] runtimeIdentifiers, bool forceSingleRid = false, bool hasPdb = true, bool addConfig = false, bool includeDebugFiles = false)
static void AddMultiRidAssembly (ApplePlatform platform, List<string> expectedFiles, string assemblyDirectory, string assemblyName, string [] runtimeIdentifiers, bool forceSingleRid = false, bool addConfig = false, bool includeDebugFiles = false)
{
if (forceSingleRid || runtimeIdentifiers.Length == 1) {
expectedFiles.Add (Path.Combine (assemblyDirectory, $"{assemblyName}.dll"));
if (hasPdb && includeDebugFiles)
if (includeDebugFiles)
expectedFiles.Add (Path.Combine (assemblyDirectory, $"{assemblyName}.pdb"));
if (addConfig)
expectedFiles.Add (Path.Combine (assemblyDirectory, $"{assemblyName}.dll.config"));
Expand All @@ -435,7 +435,7 @@ static void AddMultiRidAssembly (ApplePlatform platform, List<string> expectedFi
foreach (var rid in runtimeIdentifiers) {
expectedFiles.Add (Path.Combine (Path.Combine (assemblyDirectory, ".xamarin", $"{rid}")));
expectedFiles.Add (Path.Combine (Path.Combine (assemblyDirectory, ".xamarin", $"{rid}", $"{assemblyName}.dll")));
if (hasPdb && includeDebugFiles)
if (includeDebugFiles)
expectedFiles.Add (Path.Combine (Path.Combine (assemblyDirectory, ".xamarin", $"{rid}", $"{assemblyName}.pdb")));
if (addConfig)
expectedFiles.Add (Path.Combine (Path.Combine (assemblyDirectory, ".xamarin", $"{rid}", $"{assemblyName}.dll.config")));
Expand Down

6 comments on commit ea8ad15

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

Please sign in to comment.