dotnet / dotnet/msbuild

Introduce analyzer or some other mechanism to flag builds that invoke the compiler (i.e. CoreCompile target) with same inputs and outputs to avoid race conditions

Open
#9,781 2 comments 0 reactions 0 assignees View on GitHub
Feature: Warning Waves triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 8h
Merged PRs (30d)
141

Description

Similar to https://github.com/dotnet/msbuild/issues/9553

https://github.com/dotnet/command-line-api/pull/2336 is a good example to talk about the issue. `System.CommandLine.csproj` was built twice because two additional global properties were passed in when referencing it from a specific test project. The global properties didn't affect the CoreCompile target and the compiled output at all. This resulted in a race condition as two processes were trying to copy to the same output at the same time:

> MSB4018: System.IO.IOException: The process cannot access the file '/vmr/src/command-line-api/artifacts/bin/System.CommandLine/Release/net7.0/System.CommandLine.deps.json' because it is being used by another process. [/vmr/src/command-line-api/src/System.CommandLine/System.CommandLine.csproj::TargetFramework=net7.0]

99% of the time this is unintentional and it would be great if msbuild could flag that somehow via an analyzer or some other means.

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.