Skip to content
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

Do not throw "Both a MSBuild project file and solution file found" when the solution is just pointing to a single project file #2227

Open
xPaw opened this issue Feb 7, 2025 · 2 comments
Labels
Feature Request This issue is requesting an enhancement or new feature

Comments

@xPaw
Copy link

xPaw commented Feb 7, 2025

... 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.

@JoeRobich
Copy link
Member

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

@JoeRobich JoeRobich added the Feature Request This issue is requesting an enhancement or new feature label Feb 8, 2025
@xPaw
Copy link
Author

xPaw commented Feb 8, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request This issue is requesting an enhancement or new feature
Projects
None yet
Development

No branches or pull requests

2 participants