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
- Specify the
.slnor.csprojpath in the command. - Use this consistently across build/test/publish steps.
explicit target
dotnet build ./MyApp.sln -c ReleaseRun from the project directory
- Change into the directory that holds exactly one project.
- 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
C# "CS0017: Program has more than one entry point defined" in CIFix C# "CS0017: Program has more than one entry point defined" in CI - two Main methods (or top-level stateme…
MSBuild "MSB4018: The X task failed unexpectedly" in CIFix MSBuild "MSB4018: The X task failed unexpectedly" in CI - a build task threw an unhandled exception, ofte…
MSBuild "MSB4181: task returned false but did not log an error" in CIFix MSBuild "MSB4181: The X task returned false but did not log an error" in CI - a wrapped task failed silen…