Friday, December 25, 2009

Visual Studio 2010 SharePoint templates shortcuts to deploy and retract WSP package

I'm a sucker for shortcuts - there I said it :) So what is more obvious then setup shortcuts to deploy and retract WSP package with in Visual Studio.

For setting shortcuts in Visual Studio

Go to Tools -> Options -> in the left menu select "Keyboard"

 

For deployment

Write "Build.DeploySelection" in the "Show commands containing:"

clip_image001

In the "Press shortcut keys:" press the shortcuts you wish to use. I used Ctrl+Shitf+Alt+B and D - WSPBuilder style!

For retracting the WSP package:

clip_image002

Wednesday, December 23, 2009

Tips to deploying/debugging

Just like when debugging a normal .NET application you need to restart the app domain to load the new code and get the debugger to attach the code. In a normal SharePoint project you need to attach to the w3wp.exe process, the w3wp.exe is the application pool that runs the SharePoint instant, to load the new code, you need to restart the application pool by doing an iisreset or just recycle the application pool e.g. thought IIS manager. The sandbox solution is not run by the w3wp.exe, but a SharePointUserCode worker process (SPUCWorkerProcess.exe). This is managed by the Windows services "Windows SharePoint Services User Code Host V4" (SPUserCodeV4). So by restarting this service the sandbox solution code the now reloading next time the code is requested and ready to get debugged. So how to restart this services? One way is to start services.msc and restart the service that way or use net stop/net start or just use Power Shell.

So by run this Power Shell "restart-service -name spusercodev4" the Services User Code Host gets restarted, but you need to do this manually every time you redeployed your sandbox solution code. So to overcome this, just add a line to the "Pre-build events command line" in your Visual Studio project "powershell restart-service -name spusercodev4" and it will do the trick.

Buld events

Monday, December 21, 2009

Debuging Sandbox Solutions

When debugging a normal SharePoint project, like a Visual Web Part, you will attach Visual Studio debugger to the w3wp.exe but when debugging the sandbox solution you need to attach Visual Studio to an another process. For the sandbox solution code you need to attach to SPUCWorkerProcess.exe and this goes also for the sandbox solution proxy arguments class.

clip_image001[4]

For the sandbox solution proxy operation you need to attach to the SPUCWorkerProcessProxy.exe

clip_image002[4]

Sunday, December 6, 2009

A great ULS Viewer

I found this great ULS Viewer, I use to read the SharePoint log files with. One of the really cool things is the highlight function that’s build in, just by hover over a text the same text is high with a yellow background, soo cool :) But two of the most import features is to hide lines in the log and runtime-feed. Runtime-feed is to setup a "watch" on a directory and all now log (both lines in the current log file and lines in new log files is imbedded into the ULS Viewer view) .

clip_image001

clip_image002

clip_image003

A copy-pasting Microsoft own feature list:

  • Highlight data of importance to the user on the fly
  • Bookmark log entries
  • Append logs to other logs in order to track trends
  • Hide unimportant data
  • Only view critical log entries by sorting data by severity
  • Write rules to prompt the user when certain events occur
  • View your data in a spreadsheet instead of the text file ULS generates
  • Monitor remote machines logs that are running ULS services
  • Open multiple logs at the same time in order to compare log files.
  • Open logs files from multiple machines at the same time.

More screenshots of USL Viewer

Read more about this greater log reading tool at http://code.msdn.microsoft.com/ULSViewer