71

My solution contains multiple projects which can be started. SometimesI would like to start a single project without using my solution startup projects settings. When I right-click on the project, I can navigate to Debug->Start New Instance, which starts the application with debugger.

But I would like to start a new instance without debugger. Is this possible?

1

15 Answers 15

22

Maybe this is new in VS 2015 but there's no need to add a custom macro - you can find the Start Without Debugging menu item in the list of things you can add.

Go to Tools -> Customize, follow the images below.

Hit Add Command Here you can find the menu item

5
  • Great answer, especially that VSCommands for Visual Studio 2015 doesn't seem to have this facility yet. Also, adding a new command this way is not 2015 specific as it existed in previous versions too.
    – Jerry
    Commented Feb 8, 2016 at 10:56
  • 57
    The problem is that it always starts the StartUp project, not the project under the context menu.
    – Yegor
    Commented Jun 8, 2016 at 6:46
  • 10
    ..seriously what were the programmers thinking? Why would I add to each project a button which always only activates the startup project is beyond me... Commented Sep 30, 2016 at 7:50
  • 1
    This is especially annoying because "Start new instance" does actually start the project under the context menu, but it starts it in Debug.
    – Ishmael
    Commented May 2, 2019 at 15:23
  • 1
    Unfortunately this is not the correct answer as @Yegor stated. Commented Dec 15, 2019 at 10:48
17

If you are interested in permanent solution then I have written a small macro for this task. It does following things :

  1. Gets current selected project ( it will use first selected project, if you have selected multiple projects.)
  2. Saves the current Startup Project
  3. Sets the current selected project as Startup project and Runs the current selected project in "Start without Debug" Mode.
  4. Restores the Initial Startup Project as Startup Project.

Below is the Macro that I have written and the procedure how to do it.

How to write Macro : First thing you need to go to Visual Studio Tools --> Macros --> Macro Explorer. Once you got that right click on MyMacros and create a new module (I called it CollapseAll).

Now edit the new module (double-click on it) erase whatever is in there and paste this stuff into it.

Sub RunSelectedWithoutDebug()
            Dim Projs As Array
            Dim Proj As Project
            Projs = DTE.ActiveSolutionProjects()
            If (Projs.Length > 0) Then
                Proj = Projs.GetValue(0)
                Dim Prop As EnvDTE.Property
                Prop = DTE.Solution.Properties.Item("StartupProject")
                Dim PrevStartup As Object
                PrevStartup = Prop.Value
                Prop.Value = Proj.Name
                DTE.ExecuteCommand("Debug.StartWithoutDebugging")
                Prop.Value = PrevStartup
            End If
        End Sub

How to bind macro to keyboard shortcut : To do this you need to go to Tools-->Options-->Environment-->Keyboard. Pick your macro from the listBox with all the default VS stuff (remember it will be there like MyMacros.Module1.RunSelectedWithoutDebug) and then assign a hotkey combination or chord to it and save.

Note : Fourth step is creating a problem and spawns an annoying messagebox saying : The build must be stopped to change the solution property. Stop the build? Ok or Cancel. I used to hit Ok for the timebeing. If you dont have any problem if the macro sets up current selected project as Startup project than please comment last line of macro Prop.Value = PrevStartup by putting ' at the start of line.Now the messagebox will not come.

I am looking into it and will post the updated macro once i solve it ( if I can :) )

1
17

Add VSCommands extension into Visual Studio, right click a project -> Debug -> Start Without Debugging

Visual Studio 2022 update: there is a default menu option to start a project without debugging: enter image description here

2
  • 1
    unfortunately it's not available for VS 2008 :(
    – MikeD
    Commented Jan 7, 2014 at 19:58
  • 1
    The development of the extension VSCommands for VS2015 seems abandoned.
    – Nicolas
    Commented May 15, 2017 at 13:25
8

I just put together this macro.. It's a combination of several snippets I found around the interweb. If the project is configured to run the default project output, it will find and run that. If it's configured to run a specific program, it will run that. This macro will NOT compile your application either, so you'll want to make sure it's compiled before you run the macro. At the same time, this macro doesn't suffer from the problem mentioned in Mahin's macro above.

Sub RunActiveProjectOutput()
    Dim Projs As Array
    Dim Proj As Project
    Projs = DTE.ActiveSolutionProjects()
    If (Projs.Length > 0) Then
        Proj = Projs.GetValue(0)

        Dim action = DirectCast(Proj.ConfigurationManager.ActiveConfiguration.Properties.Item("StartAction").Value, Integer)

        If (action = 1) Then
            Dim app = Proj.ConfigurationManager.ActiveConfiguration.Properties.Item("StartProgram").Value
            Dim args = Proj.ConfigurationManager.ActiveConfiguration.Properties.Item("StartArguments").Value
            System.Diagnostics.Process.Start(app, args)
        Else
            Dim fullPath = Proj.Properties.Item("FullPath").Value.ToString()
            Dim outputPath = Proj.ConfigurationManager.ActiveConfiguration.Properties.Item("OutputPath").Value.ToString()
            Dim outputDir = System.IO.Path.Combine(fullPath, outputPath)
            Dim outputFileName = Proj.Properties.Item("OutputFileName").Value.ToString()
            Dim assemblyPath = System.IO.Path.Combine(outputDir, outputFileName)
            System.Diagnostics.Process.Start(assemblyPath)
        End If
    End If
End Sub
4
  • Great! I like the fact that it doesn't try to switch the startup project (which does not work if you are already debugging) Commented Dec 2, 2010 at 19:35
  • This dose not work with MVC projects for some reason. It starts NUnit for me. Do you have any idea of how I can get it to work?
    – unkownt
    Commented Feb 13, 2011 at 11:49
  • @unknownt Could you try debugging the macro to determine what path is taken? Also provide the values of the variables associated with that path. Commented Feb 22, 2011 at 16:25
  • @unkownt This macro relies on properties that are specific to C# projects that build into an executable. Any other project type (ASP.NET / Azure / Silverlight / what-have-you) will not work, and it would be incredibly non-trivial to make it work (ie, to manually do all the work VS does when launching an ASP.NET app - launch the appropriate webserver, browser, etc..)
    – Omer Raviv
    Commented Jan 22, 2012 at 9:19
4

I've been trying to do the same thing. It seems like an oversight by the VS team that you can start with or without debug at the solution level, but only with debug at the project level.

One thing that I've noticed is that if you right-click on a toolbar and choose "Customize", in the popup window of actions, go to Category "Project". In there, there is a command for "Run" and "Run Selected". Interesting, I added both to my project context menu, and to the main button bar, and the items seem to always be disabled.

Also interesting, the project context menu's "Debug | Start New Instance" command is nowhere to be found in the list of customizable commands. I looked through almost every category and couldn't find it.

Hopefully someone comes up with a good way to do this... it would be really handy!

1
  • Thanks for sharing. I also thought about adding the run. And I'm talking about 2017! Commented Mar 8, 2017 at 21:54
4

Here is the the way to solve problem related to Mahin's macro

Problem description: Fourth step is creating a problem and spawns an annoying messagebox saying : The build must be stopped to change the solution property. Stop the build? Ok or Cancel.

Public Module Custom
    Private WithEvents t As Timers.Timer

    Private Prop As EnvDTE.Property
    Private PrevStartup As Object

    Private Sub StartTimer()
        t = New Timers.Timer
        t.Interval = 0.05
        t.Start()
    End Sub

    Sub t_Elapsed(ByVal ee As Object, ByVal dd As Timers.ElapsedEventArgs) Handles t.Elapsed
        If DTE.Solution.SolutionBuild.BuildState <> vsBuildState.vsBuildStateInProgress Then
            t.Stop()
            Prop.Value = PrevStartup
        End If
    End Sub

    Sub RunSelectedWithoutDebug()
        Dim Projs As Array
        Dim Proj As Project
        Projs = DTE.ActiveSolutionProjects()
        If (Projs.Length > 0) Then
            Proj = Projs.GetValue(0)
            Prop = DTE.Solution.Properties.Item("StartupProject")

            PrevStartup = Prop.Value
            Prop.Value = Proj.Name
            DTE.ExecuteCommand("Debug.StartWithoutDebugging")
            StartTimer()
        End If
    End Sub
End Module

Enjoy !

4

Right-click on the solution, select Properties. Select Multiple startup projects. A combobox for each project allows you decide which projects to start without debugging.

1
  • This works but uncomfortable since I have to switch that settings everytime when I wanna run other project in same solution.
    – wsys
    Commented Dec 21, 2022 at 0:42
3

Use Start without debugging under Debug menu, or

Ctrl+F5

or you can modify the web.config file for the project:

<compilation debug="false"/>
6
  • 6
    That is going to start all the projects, not just one. Commented Aug 31, 2009 at 9:13
  • 1
    @MarkSeemann Actually it will start only the project which was set as StartUp. Commented Aug 12, 2013 at 17:56
  • 2
    @informatik01 but we have multi project startup and want to run one of them some times. Commented Mar 8, 2017 at 21:53
  • @Shimmy Em, try right clicking on the solution (i.e. NOT on the project), and selecting "Set StartUp Projects...". A modal window will open with different settings. Try to experiment with available options, maybe this will help you. P.S. The version of Visual Studio in which I saw this settings is 2015 Community Edition. Commented Mar 9, 2017 at 22:16
  • 2
    @informatik01, nops. this changes the permanent setting. I'm looking for a simple command to be able to launch a single project without debugging. Just like Alt+F5 (start new instance of single project), but without debugging. Commented Mar 10, 2017 at 0:29
3

This is pretty quick: Project | Set As StartUp Project | Current Selection. Then whichever project is selected is run under Debug | Start Without Debugging / Ctrl-f5. https://blogs.msdn.microsoft.com/saraford/2005/11/29/how-to-set-your-current-project-to-always-be-the-startup-project/

2

In short no.

What you could do is bind a key to the "Set as startup project" and then bind another key to start without debugging. Then you would have to push 2 keys to start this project without debugging, but at least it'd be quicker than using the mouse...

1

Right-Click on the project and Set it as Startup Project.

Hit Ctrl + F5

1
  • 4
    Yet the most painful if your default Startup Project is actually the one you use the most and you only rarely need to start other projects.
    – binki
    Commented Mar 27, 2015 at 15:25
1

I usually start the executable directly. If i need one solution without debugging mode a lot i usually add them to a quick launch menu somewhere on my taskbar.

2
  • Yes, but the whole problem is we cannot start without debugging a project which is not already selected as startup. Commented Sep 30, 2016 at 7:44
  • 2
    How would you start an ASP.NET Core project then? Commented Mar 8, 2017 at 21:55
1

Someone has made an addon that does this. Currently doesn't really handle aspnetcore projects though:

https://marketplace.visualstudio.com/items?temName=vurdalak1.startwithoutdebugging

2
0

an alternative way of approaching this would be to NOT use visual studio for that particular use-case and just use command line "C:\Program Files\IIS Express\iisexpress.exe" /path:%appPath% /port:%appPort%

-1
  1. Set the required project to be the Startup Project (as every has suggested)
  2. Turn off 'Build' for all other projects in the Solution Configuration Manager
  3. Start Without Debugging.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.