Skip to content
Latchkey

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

When you run dotnet build/run/test in a directory with more than one project or solution file, the tool cannot guess which one you mean. MSB1011 asks you to name the target explicitly - pass the path to the .sln or .csproj.

What this error means

The command fails immediately with MSB1011 stating the folder contains more than one project or solution file. Deterministic for the directory layout.

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 project/solution files in the directory

The working directory has more than one .csproj/.sln, so dotnet has no single default to act on.

The CI command omits the explicit target

A workflow runs dotnet build with no path, relying on a single-project assumption that no longer holds.

How to fix it

Pass the project or solution explicitly

  1. Specify the .sln or .csproj path in the command.
  2. Use this consistently across build/test/publish steps.
explicit target
dotnet build ./MyApp.sln -c Release

Run from the project directory

  1. Change into the directory that holds exactly one project.
  2. Or keep a single solution file at the repo root and always target it.

How to prevent it

  • Always pass an explicit project/solution path in CI commands.
  • Keep one solution file at the root as the canonical build target.
  • Avoid stray extra project files in build directories.

Related guides

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