installer icon indicating copy to clipboard operation
installer copied to clipboard

Specify which project file to use because this [directory] contains more than one project file.

Open piotrek-k opened this issue 5 years ago • 2 comments

I've encountered a problem while trying to execute dotnet ef migrations add [migration_name] command. While creating new project in Visual Studio 2019, I've marked an option "Place solution and project in the same directory". Here is how my project structure looks like:

λ ls
App.razor               Data/                Pages/       Shared/                       appsettings.json       docker-compose.override.yml
Areas/                  Dockerfile           Program.cs   Startup.cs                    bin/                   docker-compose.yml
BlazorApp1.csproj       Dockerfile.original  Properties/  _Imports.razor                blazor_app.sln         obj/
BlazorApp1.csproj.user  Models/              Services/    appsettings.Development.json  docker-compose.dcproj  wwwroot/

When I try to execute above mentioned command, I receive this message:

λ dotnet ef migrations add migrationname Specify which project file to use because this 'C:\Users\piotr\Desktop\webserver\blazor_app' contains more than one project file.

It makes sense, since I've got BlazorApp1.csproj and docker-compose.dcproj which are project files in the same folder. But at the same time there is no way to specify which project I want to use. People on the internet recommend to use -p and -s arguments, but documentation says that those arguments can specify path to the project folder not project file. Nonetheless I tried to use them in such way, but with no luck.

C:\Users\piotr\Desktop\webserver\blazor -> origin_app (blazor -> origin) λ dotnet ef -p BlazorApp1.csproj Specify which project file to use because this 'C:\Users\piotr\Desktop\webserver\blazor_app' contains more than one project file.

C:\Users\piotr\Desktop\webserver\blazor -> origin_app (blazor -> origin) λ dotnet ef -p BlazorApp1.csproj -s BlazorApp1.csproj Specify which project file to use because this 'C:\Users\piotr\Desktop\webserver\blazor_app' contains more than one project file.

It's also worth noting I couldn't even view help to see possible parameters I could use because of this error:

λ dotnet ef --help
Specify which project file to use because this 'C:\Users\piotr\Desktop\webserver\blazor_app' contains more than one project file.

Summing up, a few things, in my opinion, should be fixed:

  • add parameter to specify which project I want to use for migration
  • OR remove "Place solution and project in the same directory" option from Visual Studio if it creates illegal project structure
  • allow to view CLI help regardless of error

piotrek-k avatar Feb 15 '20 19:02 piotrek-k

For the devs, this is still a thing

urumo avatar Oct 20 '20 01:10 urumo

Old issue triage: @ajcvickers for ef. Not sure if this is still an issue.

marcpopMSFT avatar Mar 26 '24 20:03 marcpopMSFT