5

I used to open a solution file in Visual Studio, right click a project, select "Debug" -> "Start a new instance" to start a debug session.

Can I write a powershell script to automate this? To make things easier, the automation does not have to rebuild and Project, the script only needs to start a debug session in Visual Studio executing myApplication.debug.exe

1 Answer 1

1

Visual Studio has a 'DebugExe' command-line parameter you can use to accomplish this.

param
(
    [Parameter(Mandatory = $false)]
    [String]
    $TargetFileName
)

& "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\devenv.exe" /command "Debug.Start" /debugexe "$TargetFileName"
Sign up to request clarification or add additional context in comments.

6 Comments

For me, this command launches a new visual studio instance, which then reports "Command 'Debug.Start' is not available." Any quick thoughts or should I post a whole new question?
@willmurphyscode, what version of Visual Studio were you using? From memory I tried 2013 Pro and 2015 Ent. That seems like the most likely cause of a missing command.
@willmurphscode, I just did another quick test and can confirm it works with Visual Studio 2012 Premium, 2013 Premium, 2015 RC Enterprise. I didn't have any edition of 2010 available to try though.
@SchneuNZ thanks! I'm in VS2013 Premium. I'm pretty new to PowerShell, so it's probably my mistake. I typed exactly '& "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe" /command "Debug.Start" /debugexe "PluginRegistration.exe"'. It launches VS, but refuses to attach the debugger.
You probably want to try specifying the full path and file name to the executable you want to launch. That's what I was doing.
|

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.