Set default project in dotnet run solution

I created a solution and a webapi project in its own folder. Then I added the project to the solution.

I would like to be able to run dotnet run without specifying a project, setting a default value (as in Visual Studio).

Is this possible or impossible to accomplish with the CLI?

+5
source share
1 answer

This is currently not possible with dotnet run .

dotnet run calls msbuild calls to restore and build, but asks for the actual program and arguments to run from a new static evaluation, which means that even if you add custom assembly logic to the solution (=> "project" "being built", you there is no way to run custom msbuild logic to extract these properties from other projects. (You can still relate the relative paths to the embedded executable, but this is very cumbersome and not very flexible)

This means that the best way would be to create scripts (.bat, .sh) that invoke the correct dotnet run -p my/project command for you, without requiring a lot of typing.

+4
source

Source: https://habr.com/ru/post/1272514/


All Articles