Commit 57c5a5f
authored
[One .NET] fix duplicate .pdb files for multiple RIDs (#5236)
Deploying a project that uses two `$(RuntimeIdentifiers)` will fail on
our new fast deploy system with:
Xamarin.Android.Common.Debugging.targets(589,5): Access to the path 'obj/Debug/net5.0-android/android/assets/' is denied.
at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at Xamarin.Android.Tasks.FastDeploy.DeployFileWithFastDevTool(ITaskItem file, String toolPath, String overridePath, Byte[] buffer, Byte[] compressed, LZ4Level lz4level)
at Xamarin.Android.Tasks.FastDeploy.DeployFastDevFiles(String toolPath, String overridePath)
at Xamarin.Android.Tasks.FastDeploy.RunTaskAsync()
Reviewing the log, there are some weird things happening.
Some incorrect `@(_ResolvedSymbols)` items are passed to the
`<FastDeploy/>` MSBuild task:
_ResolvedSymbols
obj/Debug/net5.0-android/android/assets/
obj/Debug/net5.0-android/android/assets/
The expectation is that `@(_ResolvedSymbols)` contain *files*, not
directories; in particular, `@(_ResolvedSymbols)` should contain
`HelloForms.pdb`!
This is caused by the contents of the `@(ResolvedFileToPublish)` item
group that is populated by the `ComputeFilesToPublish` MSBuild target
in the dotnet/sdk:
ResolvedFileToPublish
obj/Debug/net5.0-android/HelloForms.dll
obj/Debug/net5.0-android/android.21-arm64/HelloForms.pdb
obj/Debug/net5.0-android/android.21-x86/HelloForms.pdb
The `HelloForms.pdb` files listed here do not actually *exist*; the
path should be: `obj/Debug/net5.0-android/HelloForms.pdb`.
This is caused by the way our "outer" build (51fb93e) has no
`$(RuntimeIdentifer)`, while we have an "inner" build that's per-RID.
The "inner" build needs to fix up the `@(_DebugSymbolsIntermediatePath)`
item group to account for this; see the
[`ComputeResolvedFilesToPublishList` MSBuild target][0].
We were already fixing up `@(IntermediateAssembly)`.
When `HelloForms.dll` did not map to a single `HelloForms.pdb`, the
`%(DestinationSubPath)` item metadata is not added by the
`<ProcessAssemblies/>` MSBuild task in Xamarin.Android.
Thus the following item transform generated an incorrect result:
<_ResolvedSymbols Include="@(ResolvedSymbols->'$(MonoAndroidIntermediateAssemblyDir)%(DestinationSubPath)')" />
To fix this:
* `@(_ResolvedSymbols)` should check if `%(DestinationSubPath)`
is blank.
* Call `->Distinct()` on input to the `<ProcessAssemblies/>`
MSBuild task.
* Patch up the `@(_DebugSymbolsIntermediatePath)` item group, so
that it uses the proper value for `@(IntermediateOutputPath)` of
the outer build.
See dotnet/msbuild for the definition of the
[`@(_DebugSymbolsIntermediatePath)` item group][1].
After these changes, the `@(ResolvedFileToPublish)` item group appears
correct now:
ResolvedFileToPublish
obj/Debug/net5.0-android/HelloForms.dll
obj/Debug/net5.0-android/HelloForms.pdb
and `HelloForms.pdb` now makes it to the `.apk` file as well.
Other changes:
* Updated a test to look for `UnnamedProject.pdb` during a multiple
RID build.
* I removed the `Removing duplicate: ...` log message, as it was
printing hundreds of log messages that aren't particularly useful.
[0]: https://github.com/dotnet/sdk/blob/ee455863aa6ddf13108bb54b37a5a47fb12fe39e/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets#L522-L555
[1]: https://github.com/dotnet/msbuild/blob/65d31a0151b072b910d9ea16e152265d467e3239/src/Tasks/Microsoft.Common.CurrentVersion.targets#L3741 parent 519ca83 commit 57c5a5f
File tree
3 files changed
+15
-14
lines changed- src/Xamarin.Android.Build.Tasks
- Microsoft.Android.Sdk/targets
- Tasks
- Tests/Xamarin.Android.Build.Tests
3 files changed
+15
-14
lines changedLines changed: 10 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
36 | 40 | | |
37 | 41 | | |
38 | 42 | | |
| |||
67 | 71 | | |
68 | 72 | | |
69 | 73 | | |
70 | | - | |
71 | | - | |
| 74 | + | |
| 75 | + | |
72 | 76 | | |
73 | 77 | | |
74 | 78 | | |
| |||
121 | 125 | | |
122 | 126 | | |
123 | 127 | | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
128 | 132 | | |
129 | 133 | | |
130 | 134 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
| 69 | + | |
75 | 70 | | |
76 | 71 | | |
77 | 72 | | |
| |||
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
360 | 360 | | |
361 | 361 | | |
362 | 362 | | |
| 363 | + | |
| 364 | + | |
363 | 365 | | |
364 | 366 | | |
365 | 367 | | |
366 | 368 | | |
367 | 369 | | |
368 | | - | |
| 370 | + | |
369 | 371 | | |
370 | | - | |
| 372 | + | |
371 | 373 | | |
372 | 374 | | |
373 | 375 | | |
| |||
0 commit comments