Skip to content

/errors/dotnet-cli/msb1011-more-than-one-project-or-solution-file

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

verified onenvironmentlocal · windows 10.0.26200 arm64 · GNU bash 5.3.15 (Git Bash) · 10.0.401updated
tool
.NET CLI
exit code
1
versions
.NET 6 – 10 SDK
os
any

MSB1011: Specify which project or solution file to use because this folder contains more than one project or solution file. means dotnet build (or test, restore, publish, msbuild) was run without a path in a folder with several .sln/.slnx/.csproj files, so MSBuild cannot guess which one you mean. Name it on the command line: dotnet build App.csproj or dotnet build MySolution.sln.

Reproduce it

bash
cat > App.csproj <<'EOF'
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net10.0</TargetFramework>
  </PropertyGroup>
</Project>
EOF
cp App.csproj App.Copy.csproj
dotnet build

Output · exit 1

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

Fix

Pass the project or solution file:

bash
cat > App.csproj <<'EOF'
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net10.0</TargetFramework>
    <OutputType>Library</OutputType>
  </PropertyGroup>
</Project>
EOF
cp App.csproj App.Copy.csproj
dotnet build App.csproj -v q -nologo 2>&1 | grep -E "error|Build succeeded" | sed -E 's/ in [0-9.]+s$//'

Output

Build succeeded.

Typical layouts

Folder contentsCommand
MySolution.sln and App.csprojdotnet build MySolution.sln (builds every project in it)
App.csproj and App.Tests.csprojMove the tests to their own folder, or dotnet build App.csproj
MySolution.sln and MySolution.slnxKeep one format; .slnx is the newer XML solution format

dotnet run reports the same situation differently: it asks you to pick a project with --project. See the related page on Couldn't find a project to run.

Sources