Multiple MSBuild project files found in '...'. Specify which to use with the --project option. means the folder you ran dotnet user-secrets in holds more than one .csproj, and the tool will not guess which one you meant. Add --project with the file name, for example --project Two.Web.csproj, and the command runs.

In the test list, init and set each failed without it in that folder and worked with it. Two.Web, Two.Worker, SolDir, App and the value are this test's own names. The commands on this page ran in cmd.

The error

[cwd ...\cfg\Two]
dir /b *.csproj
Two.Web.csproj
Two.Worker.csproj
exit=0
dotnet user-secrets list
Multiple MSBuild project files found in 'C:\...\fixes11\cfg\Two'. Specify which to use with the --project option.
exit=1

The path is shortened; nothing else changed. init in the same folder failed with the same text, wrapped in an exception and a short stack:

dotnet user-secrets init
System.IO.FileNotFoundException: Multiple MSBuild project files found in 'C:\...\fixes11\cfg\Two'. Specify which to use with the --project option.
   at aspnetcoretools!<BaseAddress>+0x2b6ab2
...
Command failed : Multiple MSBuild project files found in 'C:\...\fixes11\cfg\Two'. Specify which to use with the --project option.
exit=1

Why it happens

The store the tool reads and writes is named by one project's UserSecretsId, so it needs one project. With no --project it took the current folder, found two project files there and stopped before doing anything. The test folder held a web project and a copy of its project file under a second name.

A solution folder gives a different message. Here the folder held Sol.sln and the project in a subfolder App, and the tool did not read the solution:

[cwd ...\cfg\SolDir]
dir /b
App
Sol.sln
exit=0
dotnet user-secrets list
Could not find a MSBuild project file in 'C:\...\fixes11\cfg\SolDir'. Specify which project to use with the --project option. Use --file option for file-based apps.
exit=1

The fix

[cwd ...\cfg\Two]
dotnet user-secrets init --project Two.Web.csproj
Set UserSecretsId to '07ec9f15-a647-4da2-8d8e-acbecb5ec040' for MSBuild project 'C:\...\fixes11\cfg\Two\Two.Web.csproj'.
exit=0
dotnet user-secrets set "Api:Key" "fix11-two-web-test-value" --project Two.Web.csproj
Successfully saved Api:Key to the secret store.
exit=0
dotnet user-secrets list --project Two.Web.csproj
Api:Key = fix11-two-web-test-value
exit=0

The value is a made-up string for the test. From the solution folder, --project App (the subfolder) reached the project: it answered with Could not find the global property 'UserSecretsId', because that project had never been initialised, which is the next step and its own error. Run dotnet user-secrets init --project App from the same folder for that one: in the test it set a new id, and list --project App then printed No secrets configured for this application.

How it was reproduced

SDK 11.0.100 on Windows 11. Folder Two: dotnet new web -f net10.0 -n Two.Web -o . and the project file copied to Two.Worker.csproj. Folder SolDir: dotnet new sln -n Sol --format sln, a web project from dotnet new web -f net10.0 -n App -o App in App, added with dotnet sln Sol.sln add App\App.csproj. Every command shown without a PS> marker ran in cmd: a PowerShell script passed it as cmd /c ... 2>&1 and printed the exit= line after it.

Frequently asked

How do I fix Multiple MSBuild project files found for dotnet user-secrets?
Add --project with the project file name, for example dotnet user-secrets list --project Two.Web.csproj. In this test init, set and list all worked with the option in the folder that held two project files.
Can I run dotnet user-secrets from the solution folder?
In this test's solution folder, dotnet user-secrets list without --project printed Could not find a MSBuild project file; list and init with --project and the project's subfolder name reached the project.
Does dotnet user-secrets init also need --project?
Yes when the folder holds two project files. Without it init failed with the same Multiple MSBuild project files message; with --project it set a UserSecretsId in the named project.

More decoded errors in the Fixes category. For the message the solution folder led to, see Could not find the global property 'UserSecretsId'.