Skip to content
Latchkey

dotnet "MSB1011: Specify which project or solution file to use" in CI

A dotnet build/test/run with no project argument ran in a directory that has more than one .sln/.csproj, so the SDK cannot decide what to build and stops with MSB1011.

What this error means

A dotnet command without an explicit project/solution fails with MSB1011 saying the folder "contains more than one project or solution file". It happens when CI runs the command from a directory with multiple candidates.

dotnet build output
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 solution/project files in the folder

The working directory holds more than one .sln (or .csproj), so a bare dotnet build/test is ambiguous and the SDK refuses to guess.

Command run from the wrong directory

A step expected a single-project folder but ran from the repo root (or a shared folder) where several projects/solutions live.

How to fix it

Pass the explicit project or solution

Name the exact file so there is no ambiguity.

Terminal
dotnet build MyApp.sln -c Release
# or a specific project
dotnet test tests/MyApp.Tests/MyApp.Tests.csproj

Set the working directory to the right project

Run the command where exactly one project/solution lives.

.github/workflows/ci.yml
- run: dotnet test -c Release
  working-directory: tests/MyApp.Tests

How to prevent it

  • Always pass the explicit project/solution to dotnet build/test in CI.
  • Avoid running bare dotnet commands from folders with multiple candidates.
  • Set working-directory deliberately for project-scoped steps.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →