Add warning when using --framework with solution files #51561
+79
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Using
--frameworkon a solution build causes all projects to build for that framework, leading to referenced projects building multiple times and potential file lock contention.Changes
Strings.resxthat fires when--frameworkis used on solution buildsFrameworkOption: UpdatedCommonOptions.csto forward_CommandLineDefinedTargetFramework=trueproperty when--frameworkCLI option is used_CheckForSolutionLevelTargetFrameworkinMicrosoft.NET.Sdk.Solution.targetsto detect and warn before Build/Publish/Clean/Test targetsBehavior
Follows the same pattern as the existing
--outputwarning (NETSDK1194).Original prompt
This section details on the original issue you should resolve
<issue_title>dotnet build --framework builds referenced project twice</issue_title>
<issue_description><!--
Please keep in mind that the GitHub issue tracker is not intended as a general support forum, but for reporting non-security bugs and feature requests.
If you believe you have an issue that affects the SECURITY of the platform, please do NOT create an issue and instead email your issue details to [email protected]. Your report may be eligible for our bug bounty but ONLY if it is reported through email.
For other types of questions, consider using StackOverflow.
-->
Describe the bug
dotnet buildwith--frameworkbuilds the same project twice in parallel, if it is referenced by a solution and a ProjectReference. Without--framework, it builds only once.To Reproduce
Dep.sln
One/One.csproj
One/Class1.cs
Two/Two.csproj
Log of
dotnet build --framework net6.0becoming unexpectedly parallel and attempting to access a locked file