Change startup project automatically

前端 未结 4 464
生来不讨喜
生来不讨喜 2021-02-05 13:46

Just had an unfortunate accident in a multi-project solution where after adding a new project to the solution, writing some code and hitting F5 the project that ran

相关标签:
4条回答
  • 2021-02-05 14:12

    You can do something in Visual Studio that allows you to run the project without worrying about setting a Startup Project and let Visual Studio decide depending on the current selection. To achieve this, right-click on the solution explorer, choose properties. Next select Startup Project, from there select Current Selection from the Radio Button List. By doing this,whatever project you highlight in the Solution Explorer (or file you select in the text editor) will now become the current startup project.

    0 讨论(0)
  • 2021-02-05 14:12

    The F5 button is tied to whatever project is marked as "startup" and imho having VS "switch" startup project would be an awful feature and one of the first I'd disable after installing.

    However, you can set a shortcut for starting new project instance via class view context menu, open Tools->Options->Keyboard and filter the list for "ClassViewContextMenus.ClassViewProject.Debug.Startnewinstance", set it's shortcut below for something handy like Alt + F5 (yes, you can replace just the F5 if you want). You can now run "current" project (project that holds currently focused source file or parent project of a file selected in the class view etc.) with this shortcut.

    0 讨论(0)
  • 2021-02-05 14:13

    You can also set a shortcut for swapping the start up project, if that helps

    Project.SetasStartupProject to Ctrl+Shift+P (for example)

    https://blog.michaelckennedy.net/2007/07/30/visual-studio-tricks-series-1-set-as-startup-project/

    0 讨论(0)
  • 2021-02-05 14:20

    The options for startup projects can be found by right-clicking on the solution and selecting "Set Startup Projects". The options are pretty straightforward:

    • Current selection
    • Single startup project
    • Multiple startup projects
    0 讨论(0)
提交回复
热议问题