SharePoint 2007 WSPBuilder Development Cycle
I have been asked a couple times now to onboard new people the SharePoint 2007 project that I am working on. While these developers are confident in their ability to address problems and to troubleshoot, they are stymied by the debugging and troubleshooting process in SharePoint. Hence this article.
First of all, get WSPBuilder (http://wspbuilder.codeplex.com/, it will make your life much easier and the Visual Studio integration works well and automates many procedures you would being doing manually.
12 Hive Asset Development
So there are a couple streams that you might follow when you are working in SharePoint, if you are dealing with something that lives in the 12 hive, .ascx controls, .aspx pages, and other file based resources, you are going to want to leverage the ‘Copy to 12 hive’ option listed on the WSPBuilder context menu. Pressing this does exactly what you think, copies the file from your project into the 12 hive. Reloading the page on which the control sits will then cause a re-render of the control/asset and then you can see your changes.
You can use this function at a project level to copy all resources or at an individual file level as well. A very good and handy shortcut. It should also be noted that this option is not available until you have Built and deployed a WSP as well so you are going to want to do that the first time, to create the appropriate registrations, and then use this functionality to iterate as you develop your code.
Developing Code Solutions (DLLs in the GAC)
Here you are going to want to leverage first the build process and then you are going to want to copy them into the GAC. You can also find this option on the WSPBuilder context menu in visual studio. Again you are going to need to deploy a WSP for the first time and then after that you can use this shortcut. Jumping back to your page and reloading will allow you to see your changes.
You will notice that pages take longer to load this way and it is because the Application Pool needs to be reset when DLL changes are made to the GAC. Be patient, it is the fastest route that you can take in SharePoint development unfortunately.
Debugging
On the WSPBuilder context menu there is an option way down at the bottom that says, ‘Attach to worker processes’. This is your debugging shortcut. It will automatically put Visual Studio into debug mode and attach the debugger to all your running w3wp.exe processes which will effectively allow you to debug your code. One thing to watch out for is that you compiled code in that GAC will need to be the same DLL that is in your local debug directory. If it is not hitting your breakpoints, or your breakpoints are hollow, check to see that everything is lined up.
The general process for debugging is:
- Build
- Copy to GAC
- Reload Page
- Wait…
- Attach Debugger
- Wait…
- Reload Page
- Debug your code!
If you are just deploying to the 12 hive you can skip 1 and 2 and just Copy to 12 hive.
Hope that helps some people out there.
In: Programming · Tagged with: Onboarding, SharePoint 2007, WSPBuilder, WSS 3.0
