/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
cat > App.csproj <<'EOF'
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
</PropertyGroup>
</Project>
EOF
cp App.csproj App.Copy.csproj
dotnet buildOutput · 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:
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 contents | Command |
|---|---|
| MySolution.sln and App.csproj | dotnet build MySolution.sln (builds every project in it) |
| App.csproj and App.Tests.csproj | Move the tests to their own folder, or dotnet build App.csproj |
| MySolution.sln and MySolution.slnx | Keep 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
Related pages
errors · dotnet-clidotnet run: Couldn't find a project to rundotnet run says Couldn't find a project to run when the current folder has no .csproj file. cd into the project folder, or point at it with --project.errors · dotnet-clierror NETSDK1004: Assets file 'project.assets.json' not found. Run a NuGet package restoreNETSDK1004 means dotnet build ran with --no-restore, or restore never ran, so obj/project.assets.json is missing. Run dotnet restore first or drop --no-restore.commands · dotnet-clidotnet new console: create and run a C# console appdotnet new console -o MyApp creates a C# console project with top-level statements, and dotnet run builds and starts it. Options and other common templates.