Skip to content

[MAUI] MacCatalyst parallel build issueΒ #17497

Closed

Description

@jonathanpeppers

Steps to Reproduce

  1. Build dotnet/maui's repo, namely for MacCatalyst
  2. Sometimes you get errors about .pdb files such as:
Errors
    /Users/builder/azdo/_work/2/s/bin/dotnet/sdk/7.0.102/Microsoft.Common.CurrentVersion.targets(4752,5): error MSB3027: Could not copy "obj/Release/net7.0-maccatalyst/Microsoft.Maui.pdb" to "bin/Release/net7.0-maccatalyst/Microsoft.Maui.pdb". Exceeded retry count of 10. Failed.  [/Users/builder/azdo/_work/2/s/src/Core/src/Core.csproj]
    /Users/builder/azdo/_work/2/s/bin/dotnet/sdk/7.0.102/Microsoft.Common.CurrentVersion.targets(4752,5): error MSB3021: Unable to copy file "obj/Release/net7.0-maccatalyst/Microsoft.Maui.pdb" to "bin/Release/net7.0-maccatalyst/Microsoft.Maui.pdb". The process cannot access the file '/Users/builder/azdo/_work/2/s/src/Core/src/bin/Release/net7.0-maccatalyst/Microsoft.Maui.pdb' because it is being used by another process. [/Users/builder/azdo/_work/2/s/src/Core/src/Core.csproj]

I think this occurs if you have multiple MacCatalyst app projects in a solution and build them. I think it might have been introduced when RuntimeIdentifiers=maccatalyst-x64;maccatalyst-arm64 became the default? But also might be combination of some change in the .NET SDK or MSBuild.

The workaround is either:

  • Build .sln files with -m:1
  • Build with -r maccatalyst-x64

This is what I did for now:

dotnet/maui@440fd19#diff-74e588eb60cf3c891901dd5657c29e2b0b0b1e605a91d5f04220301ff4a5295bR14

Expected Behavior

No build errors.

Actual Behavior

Got a build error.

Environment

This was the versions from dotnet/maui#13201

Build Logs

Too large for GitHub:

https://microsoft-my.sharepoint.com/:u:/p/jopepper/EY6Tj2IrVkxGiVeOjABGqCsBrSnSwAtaxE72O_Fy8RV8YQ?e=XCPawx

Activity

  1. rolfbjarne commented on Feb 10, 2023

    @rolfbjarne
    Member

    Is it always Microsoft.Maui.pdb, or does it happen with pdbs from other assemblies as well?

    It's also interesting to note that the source file and the destination file are identical, so it's trying to copy a file over itself.

  2. added this to the .NET 8 milestone on Feb 10, 2023
  3. added
    bug
    on Feb 10, 2023
  4. jonathanpeppers commented on Feb 10, 2023

    @jonathanpeppers
    MemberAuthor

    I think I saw it do Microsoft.Maui.Maps.pdb once. I don't think I was able to reproduce it locally, though...

  5. jonathanpeppers commented on Feb 11, 2023

    @jonathanpeppers
    MemberAuthor

    @rolfbjarne here is another example:

    https://dev.azure.com/xamarin/public/_build/results?buildId=79089&view=logs&jobId=fa417ba0-7221-55e8-0ddb-67022373081a&j=fa417ba0-7221-55e8-0ddb-67022373081a&t=28a777bb-b552-5226-8cc7-96e0eb4324c7

    /Users/builder/azdo/_work/1/s/bin/dotnet/sdk/7.0.103/Microsoft.Common.CurrentVersion.targets(4752,5): error MSB3027: Could not copy "obj/Release/net7.0-maccatalyst/Microsoft.Maui.Controls.Compatibility.pdb" to "bin/Release/net7.0-maccatalyst/Microsoft.Maui.Controls.Compatibility.pdb". Exceeded retry count of 10. Failed.  [/Users/builder/azdo/_work/1/s/src/Compatibility/Core/src/Compatibility.csproj::TargetFramework=net7.0-maccatalyst]
    /Users/builder/azdo/_work/1/s/bin/dotnet/sdk/7.0.103/Microsoft.Common.CurrentVersion.targets(4752,5): error MSB3021: Unable to copy file "obj/Release/net7.0-maccatalyst/Microsoft.Maui.Controls.Compatibility.pdb" to "bin/Release/net7.0-maccatalyst/Microsoft.Maui.Controls.Compatibility.pdb". The process cannot access the file '/Users/builder/azdo/_work/1/s/src/Compatibility/Core/src/bin/Release/net7.0-maccatalyst/Microsoft.Maui.Controls.Compatibility.pdb' because it is being used by another process. [/Users/builder/azdo/_work/1/s/src/Compatibility/Core/src/Compatibility.csproj::TargetFramework=net7.0-maccatalyst]
    /Users/builder/azdo/_work/1/s/bin/dotnet/sdk/7.0.103/Microsoft.Common.CurrentVersion.targets(4752,5): error MSB3027: Could not copy "obj/Release/net7.0-maccatalyst/Microsoft.Maui.Essentials.pdb" to "bin/Release/net7.0-maccatalyst/Microsoft.Maui.Essentials.pdb". Exceeded retry count of 10. Failed.  [/Users/builder/azdo/_work/1/s/src/Essentials/src/Essentials.csproj::TargetFramework=net7.0-maccatalyst]
    /Users/builder/azdo/_work/1/s/bin/dotnet/sdk/7.0.103/Microsoft.Common.CurrentVersion.targets(4752,5): error MSB3021: Unable to copy file "obj/Release/net7.0-maccatalyst/Microsoft.Maui.Essentials.pdb" to "bin/Release/net7.0-maccatalyst/Microsoft.Maui.Essentials.pdb". The process cannot access the file '/Users/builder/azdo/_work/1/s/src/Essentials/src/bin/Release/net7.0-maccatalyst/Microsoft.Maui.Essentials.pdb' because it is being used by another process. [/Users/builder/azdo/_work/1/s/src/Essentials/src/Essentials.csproj::TargetFramework=net7.0-maccatalyst]
    

    You want this .binlog:

    image

    image

  6. rolfbjarne commented on Aug 15, 2023

    @rolfbjarne
    Member

    @jonathanpeppers have you seen this recently?

  7. jonathanpeppers commented on Aug 15, 2023

    @jonathanpeppers
    MemberAuthor

    I think if they can merge this, it would be 100% fixed: dotnet/maui#16678

    @mattleibow is there something still wrong with a MAUI+Blazor app?

  8. mattleibow commented on Aug 15, 2023

    @mattleibow
    Member

    Yeah, I tried to remove the RID in the csproj but it just failed with all the blazor things. I started a new PR for the total removal as that PR is just to make it work today.

    This PR is the remove all explicit rids: dotnet/maui#16765

  9. modified the milestones: .NET 8, .NET 9 on Sep 14, 2023
  10. jeremy-visionaid commented on Aug 20, 2024

    @jeremy-visionaid
    Contributor

    I'm seeing a now relatively frequent build collision on CI for DLLs in a large-ish MAUI project. Seems like it tries to build dependencies twice for catalyst release (maccatalyst-x64 and maccatalyst-arm64) with the same path (libraries don't have the runtime identifier included in the OutputPath and AppendRuntimeIdentifierToOutputPath only seems to apply to RuntimeIdentifier and not RuntimeIdentifiers). In Visual Studio the collision doesn't seem to occur though (and I can see that it only tries to build the catalyst DLLs once there).

    00:04:56.961 C:\Users\ContainerUser\.nuget\packages\microsoft.maui.controls.build.tasks\8.0.80\buildTransitive\netstandard2.0\Microsoft.Maui.Controls.targets(158,3): error MSB4018: The "XamlCTask" task failed unexpectedly. [C:\src\project\Controls.Maui\Controls.Maui.csproj::TargetFramework=net8.0-maccatalyst]
    00:04:56.961 C:\Users\ContainerUser\.nuget\packages\microsoft.maui.controls.build.tasks\8.0.80\buildTransitive\netstandard2.0\Microsoft.Maui.Controls.targets(158,3): error MSB4018: System.IO.IOException: The process cannot access the file 'C:\src\project\Controls.Maui\obj\Release\net8.0-maccatalyst\Controls.Maui.dll' because it is being used by another process. [C:\src\project\Controls.Maui\Controls.Maui.csproj::TargetFramework=net8.0-maccatalyst]
    00:04:56.961 C:\Users\ContainerUser\.nuget\packages\microsoft.maui.controls.build.tasks\8.0.80\buildTransitive\netstandard2.0\Microsoft.Maui.Controls.targets(158,3): error MSB4018:    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) [C:\src\project\Controls.Maui\Controls.Maui.csproj::TargetFramework=net8.0-maccatalyst]
    00:04:56.961 C:\Users\ContainerUser\.nuget\packages\microsoft.maui.controls.build.tasks\8.0.80\buildTransitive\netstandard2.0\Microsoft.Maui.Controls.targets(158,3): error MSB4018:    at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) [C:\src\project\Controls.Maui\Controls.Maui.csproj::TargetFramework=net8.0-maccatalyst]
    00:04:56.962 C:\Users\ContainerUser\.nuget\packages\microsoft.maui.controls.build.tasks\8.0.80\buildTransitive\netstandard2.0\Microsoft.Maui.Controls.targets(158,3): error MSB4018:    at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share) [C:\src\project\Controls.Maui\Controls.Maui.csproj::TargetFramework=net8.0-maccatalyst]
    00:04:56.962 C:\Users\ContainerUser\.nuget\packages\microsoft.maui.controls.build.tasks\8.0.80\buildTransitive\netstandard2.0\Microsoft.Maui.Controls.targets(158,3): error MSB4018:    at Mono.Cecil.ModuleDefinition.ReadModule(String fileName, ReaderParameters parameters) in C:\src\cecil\Mono.Cecil\ModuleDefinition.cs:line 1098 [C:\src\project\Controls.Maui\Controls.Maui.csproj::TargetFramework=net8.0-maccatalyst]
    00:04:56.962 C:\Users\ContainerUser\.nuget\packages\microsoft.maui.controls.build.tasks\8.0.80\buildTransitive\netstandard2.0\Microsoft.Maui.Controls.targets(158,3): error MSB4018:    at Microsoft.Maui.Controls.Build.Tasks.XamlCTask.Execute(IList`1& thrownExceptions) in /_/src/Controls/src/Build.Tasks/XamlCTask.cs:line 156 [C:\src\project\Controls.Maui\Controls.Maui.csproj::TargetFramework=net8.0-maccatalyst]
    00:04:56.962 C:\Users\ContainerUser\.nuget\packages\microsoft.maui.controls.build.tasks\8.0.80\buildTransitive\netstandard2.0\Microsoft.Maui.Controls.targets(158,3): error MSB4018:    at Microsoft.Maui.Controls.Build.Tasks.XamlTask.Execute() in /_/src/Controls/src/Build.Tasks/XamlTask.cs:line 38 [C:\src\project\Controls.Maui\Controls.Maui.csproj::TargetFramework=net8.0-maccatalyst]
    00:04:56.962 C:\Users\ContainerUser\.nuget\packages\microsoft.maui.controls.build.tasks\8.0.80\buildTransitive\netstandard2.0\Microsoft.Maui.Controls.targets(158,3): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [C:\src\project\Controls.Maui\Controls.Maui.csproj::TargetFramework=net8.0-maccatalyst]
    00:04:56.962 C:\Users\ContainerUser\.nuget\packages\microsoft.maui.controls.build.tasks\8.0.80\buildTransitive\netstandard2.0\Microsoft.Maui.Controls.targets(158,3): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() [C:\src\project\Controls.Maui\Controls.Maui.csproj::TargetFramework=net8.0-maccatalyst]
    
  11. rolfbjarne commented on Aug 20, 2024

    @rolfbjarne
    Member

    We build multiple RuntimeIdentifiers using the MSBuild task:

    https://github.com/xamarin/xamarin-macios/blob/bb965c1724ef510d818171186f5085ef87b3f71c/dotnet/targets/Xamarin.Shared.Sdk.targets#L390-L402

    and the MSBuild task is by default not parallel: "BuildInParallel=If true, the projects specified in the Projects parameter are built in parallel if it is possible. Default is false." (https://learn.microsoft.com/en-us/visualstudio/msbuild/msbuild-task?view=vs-2022)

    So it's somewhat of a mystery how this happens.

    @jeremy-visionaid do you have an MSBuild binlog for a build that fails?

  12. jeremy-visionaid commented on Aug 20, 2024

    @jeremy-visionaid
    Contributor

    @rolfbjarne Thanks for getting back to me so quickly! I was curious why I was getting different results on CI. Seems like it was failing with VS BuildTools 17.10.6 LTSC (with MSBuild 17.10.4), but it works locally with 17.11.0. Updating the CI environment resolves the problem. I could share the binlog with you if there's perhaps something that needs backporting to LTSC, but seems that whatever the problem is already fixed upstream - I can just use the current channel.

  13. rolfbjarne commented on Aug 20, 2024

    @rolfbjarne
    Member

    @rolfbjarne Thanks for getting back to me so quickly! I was curious why I was getting different results on CI. Seems like it was failing with VS BuildTools 17.10.6 LTSC (with MSBuild 17.10.4), but it works locally with 17.11.0. Updating the CI environment resolves the problem. I could share the binlog with you if there's perhaps something that needs backporting to LTSC, but seems that whatever the problem is already fixed upstream - I can just use the current channel.

    That's weird... I'm not aware of any fixes in this area. Parallel issues can be annoying to track down though, some completely different thing might cause the build to happen in a different order, thus avoiding the problem.

    If you have a binlog already that shows the error, I'd love to see it, otherwise don't worry about it.

  14. jeremy-visionaid commented on Aug 20, 2024

    @jeremy-visionaid
    Contributor

    @rolfbjarne Yeah, it's hard to be sure whether it truly resolves the problem yet. I was wrong about it colliding between arm64 and x64 - the error can also still occur on 17.10 if I only build maccatalyst-x64, and I can see the collision in the structured log viewer. It was occuring on most runs on 17.10 but I've yet to repro the issue on 17.11 after a few dozen runs now. I'm happy to share the binlogs with you - maybe I'd just done something wrong/silly, but is there a way I can provide it to you privately?

  15. rolfbjarne commented on Aug 21, 2024

    @rolfbjarne
    Member

    @jeremy-visionaid if you can put them on Dropbox or a similar service, and then send the link to my email (Rolf.Kvinge@microsoft.com) that would be great.

  16. rolfbjarne commented on Sep 12, 2024

    @rolfbjarne
    Member

    With help from @jeremy-visionaid, I was able to determine that this was fixed with #19990.

  17. moved this from Bugs to Done in .NET 9on Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions