dotnet / dotnet/installer

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

Open
#6,422 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
1.3k
Forks
437
Avg merge
3d 14h
Merged PRs (30d)
21

Description

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](https://stackoverflow.com/a/49367772/1804027) recommend to use `-p` and `-s` arguments, but [documentation says](https://docs.microsoft.com/en-us/ef/core/miscellaneous/cli/dotnet#common-options) 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

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing `dotnet ef migrations add migrationname` and `dotnet ef --help` in the directory containing both `BlazorApp1.csproj` and `docker-compose.dcproj`. Read the CLI handling for the `-p` and `-s` options and verify how project files are selected. Done means the intended project can be selected and help remains available in this directory.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
cli, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.