dotnet / dotnet/msbuild

[Bug]: Properties being removed from project as part of solution build, leading to race conditions.

Open
#9,179 10 comments 0 reactions 0 assignees View on GitHub
backlog bug Priority:2 triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 8h
Merged PRs (30d)
141

Description

### Issue Description

Hello! We've been having intermittent failures when building one of our solutions. It includes a library being built at the top-level as well as because it is a dependency of another project in the solution. We are running into the file access issue described [here](https://learn.microsoft.com/en-us/visualstudio/msbuild/fix-intermittent-build-failures?view=vs-2022), suggesting a race condition during the build.

I investigated the binlogs (would like to avoid posting them), and indeed there is a difference in `Properties/Global` for both of them. The build triggered because it's included as a dependency is missing `TargetFramework`. So that presumably is causing the project to be built twice.

My confusion is that the log includes a line that says
```
Removing Properties for project
```
and the project in question. It is removing one property: `TargetFramework`.

So, in summation, based on my research, the project is being built twice, leading to a race condition, because it is missing `TargetFramework`, and it is missing `TargetFramework` because something (MSBuild? dotnet?) is deciding to remove the property.

My question is, is my assessment correct? And if so, how do I get it to stop removing that property?

Apologies if this has been answered elsewhere or already filed, I couldn't find it.

### Steps to Reproduce

The command I'm running is
```
dotnet build $SOLUTION_FILE --configuration Release --self-contained True --verbosity Normal /property:WarningLevel=0 --noLogo -p:$RUNTIME_PROP_NAME=win-x64 --framework net6.0
```

### Expected Behavior

Build consistently succeeds.

### Actual Behavior

Build intermittently fails with a file access error.

### Analysis

_No response_

### Versions & Configurations

Windows 11
dotnet 6.0.406
dotnet msbuild --version outputs
```
MSBuild version 17.3.2+561848881 for .NET
17.3.2.46303
```

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.