Building solutions via CLI and passing targetframework as a global property leads to overbuilds
- Dominant language
- C#
- Stars
- 5.5k
- Forks
- 1.5k
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 133
Description
### Issue Description
When invoking msbuild with -property:TargetFramework=XXX (for example net5.0) and the projects in the solution have only
a single target framework defined(for example net5.0), then this will trigger multiple concurrent builds and can cause file access problems
### Steps to Reproduce
I've included a simplified projects setup to reproduce the problem.
See the readme.md in the zip for details about msbuild commandline I used to reproduce the problem. The important part is -property:TargetFramework=net5.0
[repro.zip](https://github.com/dotnet/msbuild/files/9955182/repro.zip)
### Expected Behavior
msbuild shouldn't build twice the requested configuration even if only a single target framework is defined.
### Actual Behavior
E:\github\github-sharpmake>"C:\Program Files\Microsoft Visual Studio\2022\Professional\Msbuild\Current\Bin\amd64\MSBuild.exe" -nologo -property:TargetFramework=net5.0 -property:Configuration=debug -maxcpucount -verbosity:m E:\repro\consoleapp1\ConsoleApp1\ConsoleApp1.sln /t:Rebuild
ClassLibrary2 -> E:\repro\consoleapp1\ClassLibrary2\bin\Debug\net5.0\ClassLibrary2.dll
ClassLibrary2 -> E:\repro\consoleapp1\ClassLibrary2\bin\Debug\net5.0\ClassLibrary2.dll
ClassLibrary1 -> E:\repro\consoleapp1\ClassLibrary1\bin\Debug\net5.0\ClassLibrary1.dll
ClassLibrary1 -> E:\repro\consoleapp1\ClassLibrary1\bin\Debug\net5.0\ClassLibrary1.dll
ConsoleApp1 -> E:\repro\consoleapp1\ConsoleApp1\bin\Debug\net5.0\ConsoleApp1.dll
ClassLibrary1 and 2 are built twice.
### Analysis
No idea
### Versions & Configurations
I think the problem can occur on any platform. I've seen build errors caused by this on macos and windows.
reproduced locally using pretty much latest msbuild.
Microsoft (R) Build Engine version 17.2.1+52cd2da31 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
17.2.1.25201
Problem occured on macos when building using dotnet build on github ci(not sure which version)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.