Set default project in solution for dotnet run

At the moment, this is not possible with dotnet run.

dotnet run does call msbuild targets to do a restore and build but queries the actually program and arguments to run from a new static evaluation, which means that even if you add custom build logic to a solution (=> the “project” being built), you don’t have a chance to run custom msbuild logic to fetch these properties from other projects. (One could still hard-code relative paths to the built executable but this is very cumbersome and not very flexible)

This means the best way would be to create scripts (.bat, .sh) that call the right dotnet run -p my/project command for you without requiring you to do much typing.

Leave a Comment