-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add warning when using --framework with solution files #51561
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Added NETSDK1234 warning string in Strings.resx - Modified FrameworkOption to set _CommandLineDefinedTargetFramework property - Added _CheckForSolutionLevelTargetFramework target in Microsoft.NET.Sdk.Solution.targets - Created FrameworkOptionTests.cs with test cases for the new warning Co-authored-by: marcpopMSFT <[email protected]>
Manual testing confirms the feature works correctly: - Using --framework on solution shows NETSDK1234 warning - Using --property:TargetFramework does not show warning - Warning appears for build, clean, publish, and test commands Changes: - Added NETSDK1234 warning string in Strings.resx - Modified FrameworkOption to set _CommandLineDefinedTargetFramework property - Added _CheckForSolutionLevelTargetFramework target in Microsoft.NET.Sdk.Solution.targets Co-authored-by: marcpopMSFT <[email protected]>
|
@baronfel in the spirit of limiting new warnings, should we only spit out this warning if the TFM is net11? People are definitely going to hit it. |
|
The problem (similar to the output path) is that we don't know at the solution-level that these targets run at if the projects target 11. We probably should create a Target similar to what Restore does and have the solution gather the TFMs of the project and flag if the TFM is present. |
|
Does this warn when |
|
Added When you commit this breaking change:
You can refer to the .NET SDK breaking change guidelines |
|
@copilot can you change the test to say "isn't recommended" rather than "isn't supported" |
|
Updated NETSDK1234 warning text per feedback to be less severe. Co-authored-by: marcpopMSFT <[email protected]>
Changed warning text from "isn't supported" to "isn't recommended" in commit 35d513c. Updated warning output: |
|
Cc @Youssef1313 and @nohwnd |
|
@copilot fix the merge conflict |
Resolved conflict in CommonOptions.cs by adapting to the new Option structure: - Uses Option<string> instead of DynamicForwardedOption<string> - Sets IsDynamic = true - Uses ForwardAsMany to forward both TargetFramework and _CommandLineDefinedTargetFramework properties - Maintains AddCompletions at the end
Summary: Add warning when using
--frameworkwith solution filesThis PR addresses the issue where using
--frameworkon a solution build can cause referenced projects to build multiple times, leading to inconsistent builds and file locking issues.Changes Made
_CommandLineDefinedTargetFramework=truepropertyImplementation Details
Similar to the existing
-o/--outputwarning (NETSDK1194), this adds warning NETSDK1234 when users specify--frameworkon a solution build.How it works:
--frameworkis used, the CLI forwards both--property:TargetFramework=<value>and--property:_CommandLineDefinedTargetFramework=true_CommandLineDefinedTargetFrameworkproperty--property:TargetFramework=<value>directly does NOT trigger the warning (as expected)Example Output
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