Wednesday, February 18, 2009

SharePoint Developer Tips & Tricks

Tip #1: Adding Intellisense When Editing XML Files in WSS v3 / MOSS 2007
All XML files, or just about every XML file I've run across so far, in Windows SharePoint Services (WSS) v3 & Mirosoft Office SharePoint Server (MOSS) 2007 is validated by SharePoint using the WSS schema file found in the 12 hive: %12HIVE%/TEMPLATES/XML/wss.xsd.
Adding an XML Schema To a Specific File In Visual Studio 2005I think it is fairly common knowledge to most developers that you can specify an XML schema for a specific file in Visual Studio. To do this, when you have the XML file open, go to the Properties toolpane and click on the ellipses for the Schema field select the Add button in the XSD Schemas dialog, browse to the wss.xsd file in the 12 hive (location listed above) and OK out of the dialogs. Click to learn more...

Tip #2: Add Command Line Shortcut to "12 Hive"
I'm not talking about creating a shortcut to the 12 Hive (the directory where just about everything WSS v3 is installed) on your desktop/Quick Launch. Like most people, I create a "12" toolbar on my Start Menu (as shown in the image to the right)... not talking about that either.
When you're in a command prompt, sometimes you need to navigate to the 12 Hive directory. But no one wants to type the directory path to c:\Program Files\Common Files\Microsoft Shared\web server extensions\12. Wouldn't it be easier if you could just type the following to get there?
c:\>cd\c:\>cd %12hive%c:\Program Files\Common Files\Microsoft Shared\web server extensions\12
Here's how u can achieve that:
1. Create a new file called SharePointCommandPrompt.cmd and insert the following text in it (if you're on a 64 bit system, you'll want to make the appropriate changes): @echo offecho Setting 12HIVE environment variable.set 12HIVE="C:\Program Files\Common Files\Microsoft Shared\web server extensions\12""C:\Program Files\Microsoft Visual Studio 8\VC\vcvarsall.bat" x86
2. After saving the file, create a new shortcut with the following target: %comspec% /k ""c:\[Path To The File You Just Created]\SharePointCommandPrompt.cmd""
3. To put a cherry on top, drag the shortcut onto your Quick Launch toolbar... should work like a champ!

To try it out, click the shortcut and type CD %12HIVE% at the command prompt. You should change directories to the root of the 12 Hive.

Tip #3: Access STSADM.EXE From any Directory in a Command Prompt
STSADM.EXE, the main administration utility for SharePoint, is still just a command line utility. You'll find it in %12HIVE%\BIN. To run it, you have to actually be in that directory... an inconvenience to me! Instead, add the directory to the PATH environment variable so you can type STSADM.EXE from any directory on your system. To do this:
1. Start -> All Programs -> Control Panel -> System

2. On the Advanced tab, click the Environment Variables button.
3. Select the variable Path and click the Edit button.
4. Add the following to the end of the Variable value field (don't forget the semicolon... the Path environment variable is a semicolon delimited string of directories):;C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN
5. OK out of all the dialogs.
Next time your system restarts, you'll be able to type STSADM.EXE at a command prompt from any directory on your system.
Tip #4: Overcome Save Site Template size limitation in SharePoint

Once I was working with a client and they mentioned that they were trying to save a site template and move it to another server while retaining the content but the size of the site prohibited this. By default there is a 10MB size limitation built in. Something clicked in my head because I recently found a fix that will increase the size limitation to whatever value you want to make it. Type the following using the STSADM utility
stsadm -o setproperty -propertyname max-template-document-size -propertyvalue 50000000
I think its pretty self explanatory with what you can do here… if you have a site that is in excess of 50MB you will use 75000000 or whatever number you come up with. But this is not the recommended practice by Microsoft.

No comments: