Quickly enter command-line parameters for Visual Studio debugging?
Solution 1
Macro below should help. Open "Tools->Macros->Macro Explorer", then create new module, edit it, and copy-paste code below. Required command is SetCommandArgsProperty. UI is not nice, but it works (VS 2005, I hope this will also work in VS 2010). Then add any shortcut you like to run this macro.
Here are some details:
- Find startup project
- Select it active configuration and find property with name "CommandArguments"
- Create edit box with the current value in it
-
Update property if OK is selected
Sub SetCommandArgsProperty() Dim newVal As Object newVal = InputValue(GetCommandArgsPropertyValue()) If TypeOf newVal Is String Then SetCommandArgsProperty(newVal) End If End Sub Function InputValue(ByVal defaultText As String) Dim frm As New System.Windows.Forms.Form Dim btn As New System.Windows.Forms.Button Dim edit As New System.Windows.Forms.TextBox edit.Text = defaultText edit.Width = 100 btn.Text = "OK" btn.DialogResult = System.Windows.Forms.DialogResult.OK frm.Text = "Input command line properties" frm.Controls.Add(btn) btn.Dock = System.Windows.Forms.DockStyle.Bottom frm.Controls.Add(edit) edit.Dock = System.Windows.Forms.DockStyle.Top frm.Height = 80 frm.Width = 300 If frm.ShowDialog() = System.Windows.Forms.DialogResult.OK Then Return edit.Text End If Return System.DBNull.Value End Function Function GetCommandArgsProperty() As EnvDTE.Property Dim solution As Solution Dim project As Project Dim sb As SolutionBuild Dim str As String Dim cm As ConfigurationManager Dim config As Configuration Dim properties As Properties Dim prop As EnvDTE.Property solution = DTE.Solution sb = solution.SolutionBuild For Each str In sb.StartupProjects project = solution.Item(str) cm = project.ConfigurationManager config = cm.ActiveConfiguration properties = config.Properties For Each prop In properties If prop.Name = "CommandArguments" Then Return prop End If Next Next End Function Function GetCommandArgsPropertyValue() Return GetCommandArgsProperty().Value End Function Sub SetCommandArgsProperty(ByVal value As String) GetCommandArgsProperty().Value = value End Sub
Solution 2
The extension CLIArgsMadeEasy 2010/2012 is a great little thing that puts the project's debug session's command line arguments right in a little text box on the visual studio toolbar, IMO, its alot easier and less tedious than using macros.
The Link
http://visualstudiogallery.msdn.microsoft.com/8159cd7d-2c81-47f3-9794-a347ec1fba09?SRC=VSIDE
You can just type CLIArgsMadeEasy in your search box in the extensions manager which will find it fairly quickly in the gallery, thats how I installed it, if you need to know. Hope this helps!
Solution 3
At least in Visual Studio 2012, you can use Alt+F7
shortcut to directly access project properties.
Furthermore, the opened Property Pages normally remembers the last opened item, i.e. Configuration Properties -> Debugging
.
paperjam
Updated on July 09, 2022Comments
-
paperjam almost 2 years
I want to change my command-line arguments and then debug my executable.
With the default Visual Studio UI, this takes me several tortuous mouse and keyboard actions:
Project ... right click ... Configuration Properties ... Debugging ... Command Arguments ... type args ... ENTER ... F5
Is there a way to make this common action as easy as other common operations, for example, searching all files for a pattern which goes:
CNTL+SHIFT+F ... type search pattern ... ENTER
For example, is there an way to create a custom edit box to allow quick access to the debug command-line arguments? Or a way to have a key-binding pop up a simple "debug dialog" where the args can be entered and debugging started directly? e.g.
ALT+F5 ... type args ... ENTER
I am using C++ and Visual Studio 2010 Express. Thanks!
-
paperjam about 13 yearsUnfortunately I only have Visual Studio Express, so no macros. But I like the soution.
-
Laurent Couvidou almost 11 years+1 ATM this version will work with VS2010 only (don't get confused by the naming...). There's a VS2012 version available here though: n0n4m3.codingcorner.net/?p=214. It works but still has some issues.
-
kdmin almost 10 yearsIs there a version for VS2013?