Alexander Kuzin
Alexander Kuzin

Reputation: 505

Passing current file name to Visual Studio debug command line arguments

I'm creating PowerShell module in VS 2012. So for comfortable debugging in debug project properties I set Start action to start external program PowerShell.exe and in command line arguments I want to add -Command { Import-Module [MyDllFileName] }. What should I write instead of [MyDllFileName]? There should be my compiled dll.

Upvotes: 0

Views: 1338

Answers (1)

stijn
stijn

Reputation: 35901

The answer propsosed in the linked question is still pretty much valid, but you have to think it through a bit.

First of all the actual answer remains: it's simply not possible to get the assembly name onto the debug command line using the project settings.

Second there are a couple of things you can do however:

  1. The debugger command line is stored in the projectname.vcxproj.user file as the LocalDebuggerCommandArguments property. Write a script/extension/... to set that property to $(TargetPath) and off you go.

  2. Based on the solution propsed in the other question: use an external tool with something like devenv /DebugExe powershell.exe - Command { Import-Module $(TargetPath) }.

  3. Like 2, but place a DebugBreak() statement somwhere in your dll and just launch PowerShell, it will coma and ask to attach the debugger when it sees DebugBreak/add.

Upvotes: 1

Related Questions