Friday, November 7, 2008

Debugging features with STSDEV

I've been banging my head for a few days trying to debug a feature receiver that I built and deployed using STSDEV. After scouring the web I found lots and lots of questions, and typically the same, incomplete, answer. To get things to work, this is what I had to do:
  1. In VS2008, click on Project->Settings->Debug. When you get to the debug settings for your project, you'll notice each of your build targets in a dropdown at the top of the page. Select a target and then scroll and click the 'Advanced' button. By default, STSDEV doesnt generate a PDB for most of its build targets, so you'll want to change the "Debug Info" drop-down selection to "full". Repeat for each build target that you need debug info to be generated for (at least DebugDeploy and DebugRedeploy).
  2. Build and deploy your solution using one of the targets you changed above.
  3. Map a drive to \\machinename\c$\windows\assembly. This allows you to see the file structure of the GAC without the shell getting in the way.
  4. Copy your just-generated PDB file from the project directory to the GAC_MSIL folder in your new mapped-drive directory. You'll need to do this each time you build. *some people say this isnt necessary, however.
  5. Attach your VS debugger to the w3wp.exe process. If there is more than one instance of w3wp running, use 'iisapp' from the command line to get a description for each one. This will help you pick.
  6. Set your breakpoints. At this point the symbols for your assembly might not be loaded (you'll get the dreaded empty-circle breakpoint). Don't worry - VS will find them.
  7. Browse to your feature-activation system page and activate your feature.

Good luck!


Anonymous said...

I need to do the same thing with VS2005. I try to follow yours steps but I don't find where I can specify if I need the debug info for each target. Do you have any idea to do this?

Umberto from Italy

Anonymous said...


Your post was very useful for me. To deploy the pdb file I added a line to the end of the section "DebugRedeploy" (or any other you wish) in "projectDir"\DeploymentFiles\Microsoft.SharePoint.targets (file generated by STSDEV):

<EXEC Command='copy /Y "$(TargetDir)$(ProjectName).pdb" "Z:\Gac_MSIL\#Your.Wepart.Namespace#\#version#__#publicToken#"' />

Replace #Your.Wepart.Namespace#, #version# and #publicToken# with the values of your webpart.

Perhaps further teaking is possible with a "CopyFiles" section instead of the "Exec" section...

"Z:" is a mapped network drive to \\\YourSharePointServerYouAreDebugginOn\windows\assembly" to enable full file access to the GAC. You can look at files with Windows Explorer which helps you to find the correct path for the copy process.

Note: I had to close and reopen VS to activate changes in Microsoft.Sharepoint.targets.

Again, let me thank you for your post.
Best Regards