Repository navigation
Make project reference traversal safe for parallel builds - #751
Merged
Merged
Conversation
kzu
enabled auto-merge (rebase)
December 2, 2026 20:48
Member
Author
🧪 Details on Ubuntu 26.04.1 LTS🧪 Details on Microsoft Windows 10.0.26100from dotnet-retest v1.0.0 on .NET 11.0.0 with 💜 by @devlooped |
Packing called referenced projects with extra global properties (FromPackagingProject, BuildingPackage, DesignTimeBuild, IsPackable, PackFolder). Each distinct set starts another configuration of the reference, which builds it (and, by inheritance, its references) again into the same obj folder. In a parallel build two of those compile at once and fail with CS2012. References are now called with the global properties a normal build uses, so GetPackageContents runs on the instance Build built: - Drop FromPackagingProject (it only fed a dead import), the DesignTimeBuild=false Xamarin.Android 9.4 workaround and BuildingPackage (the referencing project assigns package paths itself). - PrivateAssets=all passes _PackAsPrivateAssets=true, mapped to IsPackable=false in the reference, instead of IsPackable=false, which can't be told apart from a command-line global. - PackFolder, PackFrameworkSpecific and _PackAsPrivateAssets still reach the reference for GetPackageContents, since they change what it infers, but are added to _GlobalPropertiesToRemoveFromProjectReferences so they never reach the build of its own references. Co-authored-by: CodeAlta <noreply@codealta.io> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kzu
force-pushed
the
alta/sunny-deneb-gnqx
branch
from
December 3, 2026 11:00
b6949f5 to
b9c328b
Compare
This was referenced Dec 3, 2026
kzu
added a commit
to devlooped/stunts
that referenced
this pull request
Dec 3, 2026
…arallel The .NET 11 SDK passes -maxcpucount, which wins over the -m:1 of Directory.Build.rsp, and the parallel build failed with CS2012 file locks: global properties on project references built Stunts, Stunts.CodeAnalysis and Stunts.CompiledProxy again, in other configurations, into the same obj. NuGetizer 1.5.2 (devlooped/nugetizer#751) no longer passes its own global properties to referenced projects, and passes a reference's PackFolder to GetPackageContents alone. Stunts.Package now asks for the tool layout of the generator with that PackFolder instead of IsPackable=false, so the generator compiles once and only its package contents take the shape of a tool. The tool layout removes the documentation of the references it packs too, which now get its PackFolder. Two clean parallel builds compile each project and target framework once, and the packages match a serial build with NuGetizer 1.5.1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: CodeAlta <noreply@codealta.io>
This was referenced Dec 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A solution using NuGetizer packaging projects failed a plain parallel
dotnet buildwithCS2012(file used by another process);-m:1passed. The .NET 11 SDK passes-maxcpucount, so builds are parallel by default.Cause
Packing called referenced projects with extra global properties:
FromPackagingProject=true(packaging projects'ProjectReferenceitem definition),BuildingPackageandDesignTimeBuild=false(_GetReferencedPackageContents),IsPackable=falseandPackFolder/PackFrameworkSpecific(_SplitProjectReferencesByIsNuGetized). Each distinct set is another MSBuild configuration of the reference. Global properties are inherited, so those configurations also built the reference's own references (ResolveProjectReferences) into the sameobjfolder, racing with the normal build.Change
References are called with the global properties a normal build uses, so
GetPackageContentsruns on the instanceBuildbuilt:FromPackagingProject(it only fed an import of a file that isn't inbuild/), the Xamarin.Android 9.4DesignTimeBuild=falseworkaround, andBuildingPackage(the referencing project already assigns package paths to referenced contents throughIsPackaging).PrivateAssets=allpasses_PackAsPrivateAssets=true, whichNuGetizer.propsandNuGetizer.Shared.targetsturn intoIsPackable=false.IsPackableitself can't be told apart from a command-line-p:IsPackable=false.PackFolderoverride andPrivateAssets=allstill reach the reference forGetPackageContents, because they change what it infers (PackNone,PackFrameworkReferences,Microsoft.Build*dependencies, bundling of packable transitive references). They are added to_GlobalPropertiesToRemoveFromProjectReferences, so they never reach the build of the reference's own references.A binlog of a parallel solution build with
PackOnBuild=true(aPackFolderoverride,PrivateAssets=alland a transitive reference) shows the configurations with pack properties only runGetPackageContents(resolution and inference targets, noCoreCompileor copies), and each project/TFM compiles in exactly one configuration.Edge-case behavior changes: a framework-specific packaging project now retargets content of references of references to its own TFM, as it already did for direct references;
dotnet-nugetize'sDesignTimeBuild=truenow reaches references too.Tests
given_parallel_builds: a packaging project calls its references in a single configuration without pack properties; withPrivateAssets=alland aPackFolder, contents are bundled transitively, no configuration with pack properties builds, and every project compiles once.main(NuGet.Packaging 8.0,RuntimeFact("Windows")running on .NET Framework). Packaging-project, complex pack, project reference, multi-targeting, transitive and inline project tests: 149 passed, 1 skipped. The 2given_multitargeting_librariestests failed locally only because themaccatalystworkload isn't installed here (CI restores it).🤖 Generated with Claude Code
This pull request was created by CodeAlta.