dotnet / dotnet/msbuild

Building solution configurations in parallel causes races in projects

Open
#4,680 0 comments 0 reactions 0 assignees View on GitHub
Area: Solution (.sln) needs-design triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 13h
Merged PRs (30d)
133

Description

Given a solution that has some projects that don't inherit the solution configuration (for instance, an AnyCPU library in a solution that primarily builds for x86/x64), you can't build the solution in parallel with multiple configurations.

### Steps to reproduce

[MultiPlatformSolutionRace.zip](https://github.com/microsoft/msbuild/files/3560633/MultiPlatformSolutionRace.zip)

```
msbuild -nologo -m -v:m .\BuildAll.proj -bl
```

### Expected behavior

`AnyCPULibrary.csproj` builds exactly once, because it only needs to be built for Debug/AnyCPU.

### Actual behavior

```sh-session
$ msbuild -nologo -m -v:m .\BuildAll.proj
AnyCPULibrary -> S:\repro\microsoft\msbuild\issues\4678\AnyCPULibrary\bin\Debug\AnyCPULibrary.dll
MultiPlatformApp -> S:\repro\microsoft\msbuild\issues\4678\MultiPlatformApp\bin\x86\Debug\MultiPlatformApp.exe
AnyCPULibrary -> S:\repro\microsoft\msbuild\issues\4678\AnyCPULibrary\bin\Debug\AnyCPULibrary.dll
MultiPlatformApp -> S:\repro\microsoft\msbuild\issues\4678\MultiPlatformApp\bin\x64\Debug\MultiPlatformApp.exe
```

`AnyCPULibrary.csproj` is built twice, because the solution configuration is passed down as a global property, and the solution configuration differs:

```diff
Platform = AnyCPU
BuildingSolutionFile = true
CurrentSolutionConfigurationContents =
- Debug|x86
+ Debug|x64
Debug|AnyCPU

SolutionDir = S:\repro\microsoft\msbuild\issues\4678\
SolutionExt = .sln
SolutionFileName = MultiPlatformApp.sln
SolutionName = MultiPlatformApp
SolutionPath = S:\repro\microsoft\msbuild\issues\4678\MultiPlatformApp.sln
Configuration = Debug
```

### Environment data
`msbuild /version` output:

```
Microsoft (R) Build Engine version 16.3.0-preview-19426-01+faf5e5d75 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

16.3.0.42601
```

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.