xamarin / xamarin-macios

.NET for iOS, Mac Catalyst, macOS, and tvOS provide open-source bindings of the Apple SDKs for use with .NET managed languages such as C#
Other
2.42k stars 507 forks source link

[MAUI] MacCatalyst parallel build issue #17497

Open jonathanpeppers opened 1 year ago

jonathanpeppers commented 1 year ago

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:

This is what I did for now:

https://github.com/dotnet/maui/pull/13201/commits/440fd194b22649b0390f15865cf6cb94c6bc6017#diff-74e588eb60cf3c891901dd5657c29e2b0b0b1e605a91d5f04220301ff4a5295bR14

Expected Behavior

No build errors.

Actual Behavior

Got a build error.

Environment

This was the versions from https://github.com/dotnet/maui/pull/13201

Build Logs

Too large for GitHub:

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

rolfbjarne commented 1 year ago

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.

jonathanpeppers commented 1 year ago

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

jonathanpeppers commented 1 year ago

@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

rolfbjarne commented 10 months ago

@jonathanpeppers have you seen this recently?

jonathanpeppers commented 10 months ago

I think if they can merge this, it would be 100% fixed: https://github.com/dotnet/maui/pull/16678

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

mattleibow commented 10 months ago

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: https://github.com/dotnet/maui/pull/16765