Do not throw "Both a MSBuild project file and solution file found" when the solution is just pointing to a single project file
... or always format the solution. I don't see why it needs to throw this error at all when presumably it accepts the solution file pointing to multiple projects as long as they are in other folders.
Looks like MSBuild will take the solution when they both have the same name. See https://github.com/dotnet/msbuild/blob/a51113d69ff0667528ca5dc8e2775f3c912f2e65/src/MSBuild/XMake.cs#L3577
This doesn't seem to work for me:
-a--- 03/02/2025 14:43 2218 SteamDatabaseBackend.csproj
-a--- 07/11/2024 13:20 2777 SteamDatabaseBackend.sln
$ dotnet format
Unhandled exception: System.IO.FileNotFoundException: Both a MSBuild project file and solution file found in x. Specify which to use with the <workspace> argument
at Microsoft.CodeAnalysis.Tools.Workspaces.MSBuildWorkspaceFinder.FindWorkspace(String searchDirectory, String workspacePath)
at Microsoft.CodeAnalysis.Tools.Workspaces.MSBuildWorkspaceFinder.FindWorkspace(String searchDirectory, String workspacePath)
at Microsoft.CodeAnalysis.Tools.FormatCommandCommon.ParseWorkspaceOptions(ParseResult parseResult, FormatOptions formatOptions)
at Microsoft.CodeAnalysis.Tools.Commands.RootFormatCommand.FormatCommandDefaultHandler.InvokeAsync(ParseResult parseResult, CancellationToken cancellationToken)
at System.CommandLine.Invocation.InvocationPipeline.InvokeAsync(ParseResult parseResult, CancellationToken cancellationToken)
$ dotnet --version
9.0.102
Is there a workaround while we wait for this to be changed?
@BrBill simply reference one or the other. In the example from above dotnet format SteamDatabaseBackend.sln would work.