You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[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#L374
Copy file name to clipboardExpand all lines: src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.AssemblyResolution.targets
0 commit comments