How to debug IWizard-based project template

1.3k views Asked by At

I have exported a Visual Studio Template using the Export Template Wizard. The template requires some user input, so I added a Wizard assembly, which gets invoked the way it should, except for some minor things, so I need to debug.

I found a rather understandable summary on how to debug in this MSDN thread, but can't get it to work as described. Here's what I did:

In the Wizard Project (VS run as Administrator)...

  1. set a break point in my wizard's ProjectFinishedGenerating method
  2. set project settings -> build -> output path to

    Program Files\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies\

  3. set project settings -> debug -> start action to external program (Visual Studio 2010)

  4. Hit F5 to start debugger

At this point - as expected - a new VS 2010 instance opens up, but with nothing loaded. So, wherever my breakpoints were set, they won't be hit. I guess this goes back to the fact that the VSIX Template contains its own copy of the Wizard DLL, without pdbs, so probably debugging won't work with VSIX.

I've tried to get this to work the way described in the MSDN post by exporting a Template the regular way (as a ZIP), then modifying the VSTemplate within the ZIP to reference the Wizard assembly, but all I get is an error message saying that the wizard dll could not be found (not even after adding it to the GAC). And yes, it is strongly named and signed.

Can anyone point me into a direction that would help me debug my IWizard implementation?

1

There are 1 answers

0
jradxl On

The way I debug an Item template with a Wizard is as follows...

Create a solution containing a VSIX project. Add to the Solution an Item Project; Add to the Solution a Class Library that will become the IWizard. Set the VSIX project as the startup.

Now create a new solution at a close relative path. Add to that a Console App that will become a Debugging solution.

In the properties page of the VSIX solution point the Debug Tab, startup to another copy of devenv.exe with the command line devenv.exe /rootsuffix exp ....\Debugging.sln or something very similar. Now when you hit F5 the Exp Int will start up and you can add the Item Template to the debugging.sln with break points in the Wizard class library.

Now you refer to a Project Template. You may be able to adapt this post to that, or use an Item template as a test harness to what you are trying to achieve on the project template.

If you need an example of how to set this up, use the DSL lang template, choose MinLang and look at what has been created. You'll see a DSL project, a DSLPackage which is the VSIX and on disk the Debugging solution.

I do this in VS2012, which might have been improved over VS2010. I've removed my VS2010 now so can't check.