Added --framework arg to "dotnet format" to set TFM #53202
Added --framework arg to "dotnet format" to set TFM #53202JoeRobich merged 5 commits intodotnet:mainfrom
Conversation
- Alias -f is set - does only work without --folder
|
@dotnet-policy-service agree |
Passing a target framework to `dotnet restore` causes the dotnet CLI in SDK 10.0.x to emit a bare --framework switch in its internal MSBuild.dll invocation. MSBuild does not recognise that switch and exits with MSB1001. The framework argument is unnecessary for restore: dotnet restore on a solution or project already restores all target frameworks. Framework filtering is handled downstream by MSBuildWorkspaceLoader, which sets the TargetFramework MSBuild property when opening the workspace.
|
The original bug called out running into merge conflict issues as a motivation for this flag; is that the motivation here now, or is this needed for some other reason? I can imagine some other needs, but if the only motivation was the merge conflicts, then I'd hope that isn't something we can just address directly. |
My main motivation here were the merge conflicts. But looking at the problem, I quickly realized that it's also preferable to reduce the target frameworks to only one a lot of times. Aside from that, I think it could be quite useful in some CI cases, but there's currently no need on my side. |
JoeRobich
left a comment
There was a problem hiding this comment.
Thanks for reverting those changes. Once we fix the parameter order, I am good to approve this.
src/BuiltInTools/dotnet-format/Workspaces/MSBuildWorkspaceLoader.cs
Outdated
Show resolved
Hide resolved
| formatOptions, | ||
| logger, | ||
| cancellationToken, | ||
| binaryLogPath: formatOptions.BinaryLogPath).ConfigureAwait(false); |
test/dotnet-format.UnitTests/MSBuild/MSBuildWorkspaceLoaderTests.cs
Outdated
Show resolved
Hide resolved
test/dotnet-format.UnitTests/Analyzers/ThirdPartyAnalyzerFormatterTests.cs
Outdated
Show resolved
Hide resolved
|
Thanks @Hextaku |
I was really annoyed by #41899 which describes a problem with "dotnet format" when projects have multiple target frameworks, so I added support for a --framework argument to it to specify a single TFM.
Implemented Solution:
New argument "--framework" with alias "-f" which takes a TFM and restricts restore and analysis to the specified framework only.
Unit tests similar to existing dotnet format tests.
Remarks