Skip to content
Latchkey

dotnet "error MSB1011: Specify which project or solution" in CI

A dotnet command (build, test, run) found more than one project or solution in the folder and will not pick for you. MSB1011 asks you to name the exact file to operate on.

What this error means

dotnet test or build fails immediately with "error MSB1011: Specify which project or solution file to use because this folder contains more than one project or solution file."

dotnet
MSBUILD : error MSB1011: Specify which project or solution file to use because this
folder contains more than one project or solution file.

Common causes

Multiple projects or solutions in the working directory

The folder holds two .csproj files, or a .csproj and a .sln, so the command cannot infer a single target.

A command run from the repo root

Running dotnet test at the root of a multi-project repo gives the CLI nothing unambiguous to act on.

How to fix it

Name the project or solution explicitly

  1. Decide which solution or test project the step should target.
  2. Pass its path as the first argument to the command.
  3. Re-run the step.
Terminal
dotnet test tests/MyApp.Tests/MyApp.Tests.csproj

Point at the solution to cover all projects

For a build or test across the repo, pass the .sln so the CLI has a single, explicit target.

Terminal
dotnet test MySolution.sln

How to prevent it

  • Always pass an explicit project or solution path in CI.
  • Keep one solution that references the projects you build and test.
  • Avoid running ambiguous commands from the repo root.

Frequently asked questions

What causes ""error MSB1011: Specify which project or solution""?
The folder holds two .csproj files, or a .csproj and a .sln, so the command cannot infer a single target.
How do I fix "error MSB1011: Specify which project or solution"?
Name the project or solution explicitly

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card