dotnet / dotnet/msbuild

Global lock/mutex to prevent multiple MSBuild instances building the same project concurrently

Open
#9,462 29 comments 5 reactions 1 assignee Claimed by @baronfel View on GitHub
Area: Engine backlog needs-design triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 8h
Merged PRs (30d)
141

Description

Suppose you have more than one MSBuild invocations (either both command line, or a build from an IDE such as VS that is concurrent with a command-line build).

Currently we have no defense mechanisms against concurrent builds originating from different processes.

Let's brainstorm about perhaps taking a global mutex around the proj file being built (at per-project granularity). It's not clear at all what granularity should be used (around a project, around a solution?). Also the same project can be built multiple times with different targets, global properties, etc. Some of these builds have no side-effects, but some of them do. Do we only lock around builds that have side-effects?

Need to be careful here to allow multiple MSBuild.exe nodes belonging to the same build invocation to bypass the locking.

I understand it's a very fuzzy feature request, and it's going to be hard to get right, but I feel like we need some long term investment in this space. Otherwise if someone accidentally starts a build from the IDE while a command-line build is running, we can run into corruption and race conditions that are very hard to diagnose.

cc @xoofx

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.