-
Notifications
You must be signed in to change notification settings - Fork 560
[One .NET] fix duplicate .pdb files for multiple RIDs #5236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[One .NET] fix duplicate .pdb files for multiple RIDs #5236
Conversation
7ed6c31
to
4d34ee0
Compare
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) in /Users/builder/azdo/_work/18/s/xamarin-android/external/monodroid/tools/msbuild/Tasks/FastDeploy.cs:line 579 at Xamarin.Android.Tasks.FastDeploy.DeployFastDevFiles(String toolPath, String overridePath) in /Users/builder/azdo/_work/18/s/xamarin-android/external/monodroid/tools/msbuild/Tasks/FastDeploy.cs:line 491 at Xamarin.Android.Tasks.FastDeploy.RunTaskAsync() in /Users/builder/azdo/_work/18/s/xamarin-android/external/monodroid/tools/msbuild/Tasks/FastDeploy.cs:line 175 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/ This is caused by the contents of the `@(ResolvedFileToPublish)` item group: 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 Since `HelloForms.dll` doesn't map to a single `HelloForms.pdb`, the `%(DestinationSubPath)` item metadata is not added by the `<ProcessAssemblies/>` MSBuild task. And so the following item transform generates 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: https://github.com/dotnet/msbuild/blob/65d31a0151b072b910d9ea16e152265d467e3239/src/Tasks/Microsoft.Common.CurrentVersion.targets#L374 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 `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.
4d34ee0
to
6434fc4
Compare
<ProcessAssemblies | ||
InputAssemblies="@(_ResolvedAssemblyFiles)" | ||
ResolvedSymbols="@(_ResolvedSymbolFiles)" | ||
InputAssemblies="@(_ResolvedAssemblyFiles->Distinct())" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is @(_ResolvedAssemblyFiles->Distinct())
potentially stored in a file anywhere? Presumably this expression controls @(_ProcessedShrunkAssemblies)
? .Distinct()
may change the ordering, and I don't know if that ordering is consistent from one process run to the next, so if this is "somehow" stored in a file anywhere, it may result in bad dependency tracking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
->Distinct()
in MSBuild preserves ordering, I asked Rainer about this before:
@(_ResolvedAssemblyFiles)
won't be used anywhere else, but the outputs of <ProcessAssemblies/>
will be.
@jonpryor I put several more details in the PR text above we can use in the final commit message. If I end up making another change, I'll copy it to the commit message. |
Context: dotnet/android#5236 Fixes problem with Fast Deployment on Android caused by incorrect paths in `@(ResolvedFilesToPublish)` from the dotnet/sdk. Hoping it might help the random iOS failure, too? We saw things in the build log such as: asset directory did not exist: /Users/runner/work/1/s/HelloAndroid/obj/Debug/net5.0-android/assets/ (TaskId:253) Executing link --manifest /Users/runner/work/1/s/HelloAndroid/obj/Debug/net5.0-android/android/manifest/AndroidManifest.xml [...] ILLINK : error MT2301: The linker step 'Setup' failed during processing. [/Users/runner/work/1/s/HelloiOS/HelloiOS.csproj] `net6-samples.sln` will build projects in parallel, so we're not sure if the Android log message is affecting the iOS build or not.
Context: dotnet/android#5236 Fixes problem with Fast Deployment on Android when building a project with multiple `$(RuntimeIdentifiers)`. There were incorrect paths in `@(ResolvedFilesToPublish)` coming from the dotnet/sdk.
Deploying a project that uses two
$(RuntimeIdentifiers)
will fail onour new fast deploy system with:
Reviewing the log, there are some weird things happening. Some
incorrect
@(_ResolvedSymbols)
items are passed to the<FastDeploy/>
MSBuild task:This is caused by the contents of the
@(ResolvedFileToPublish)
itemgroup that is populated by the
ComputeFilesToPublish
MSBuild targetin the dotnet/sdk:
The
HelloForms.pdb
files listed here do not actually exist, thepath should be:
obj/Debug/net5.0-android/HelloForms.pdb
.This is caused by the way our "outer" build has no
$(RuntimeIdentifer)
,while we have an "inner" build that runs per-RID.
The "inner" build needs to fix up the
@(_DebugSymbolsIntermediatePath)
item group to account for this:
https://github.com/dotnet/sdk/blob/ee455863aa6ddf13108bb54b37a5a47fb12fe39e/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets#L522-L555
We were already fixing up
@(IntermediateAssembly)
.When
HelloForms.dll
did not map to a singleHelloForms.pdb
, the%(DestinationSubPath)
item metadata is not added by the<ProcessAssemblies/>
MSBuild task in Xamarin.Android.And so the following item transform generated an incorrect result:
To fix this:
@(_ResolvedSymbols)
should check if%(DestinationSubPath)
is blank.->Distinct()
on input to the<ProcessAssemblies/>
MSBuild task.@(_DebugSymbolsIntermediatePath)
item group, so thatit uses the proper value for
@(IntermediateOutputPath)
of theouter build.
See dotnet/msbuild for the definition of
@(_DebugSymbolsIntermediatePath)
: https://github.com/dotnet/msbuild/blob/65d31a0151b072b910d9ea16e152265d467e3239/src/Tasks/Microsoft.Common.CurrentVersion.targets#L374After these changes, the
@(ResolvedFileToPublish)
item group appearscorrect now:
HelloForms.pdb
now makes it to the.apk
file as well.Other changes:
UnnamedProject.pdb
during a multipleRID build.
Removing duplicate: ...
log message, as it wasprinting hundreds of log messages that aren't particularly useful.