Monday, 22 February 2010

Using WSPBuilder

I have been using WSPBuilder for a while and suddenly noticed that the documentation on the Codeplex site is a bit poor. 

For those who do not know WSPBuilder is a tool and a set of extensions which facilitates the making, deploying and debugging of SharePoint features.

Creating a WSPBuilder Project

Select WSPBuilder from the project types, then select either “WSPBuilder Project” or “WSPBuilder Project with Workflow”

clip_image002

 

clip_image004

Then we need to add a project item to do so select Project | Add New Item (or your preferred method) from the Categories select WSPBuilder and select the most appropriate item for your project.

 

 

 

clip_image006Complete this dialog, this sets the information which is found in the Manage Features section of your SharePoint site. Scope is quite important as this sets the visibility. See http://msdn.microsoft.com/en-us/library/ms476615.aspx

 

You will now notice that the Feature directory layout has been created. Along with the elements.xml and Feature.xml.

Finally the real magic! By right clicking on the project you get the WSPBuilder Menu. This menu has the following items.

· clip_image010Build WSP – This creates a WSP File

· Deploy – Deploys the WSP to the server
· Upgrade – Upgrades existing feature
· Uninstall – Removes the WSP from the server
· Copy to 12 hive – Does not deploy but rather copies the information
· Copy to GAC – Copies assemblies to the GAC
· Recycle AppPools
· Recycle Services Timer
· Create Deployment Folder – Creates a setup.exe
· Attach to IIS Worker Process – this attaches the code to the correct W3Wp.exe process (invaluable)

Friday, 19 February 2010

WSP Feature Deployment and Uninstalling

I need to deploy / uninstall some features which I have created and not having access to the servers and not wanting to create complicated release notes, I came up with the following batch file

it is called with 2 or 3 parameters; the first is the wsp name, the second the server and the third “U” or “u” if you want to uninstall it.

I am sure everyone will have their own bit they want to do, but it is a start.

ECHO OFF

SET wspname=%1
SET wspname=%wspname:.wsp=%

If [%1] == [] GOTO USAGE
If [%2] == [] GOTO USAGE
If [%3] == [U] GOTO UNINSTALL
If [%3] == [u] GOTO UNINSTALL

ECHO ************** INSTALL %1 ***************
ECHO ON

stsadm -o addsolution -filename %1
stsadm -o execadmsvcjobs
stsadm -o deploysolution -name %1 -immediate -allowGacDeployment -force
stsadm -o execadmsvcjobs
stsadm -o activatefeature -filename "%wspname%\feature.xml" -url %2
GOTO END

:UNINSTALL

ECHO ************** UNINSTALL %1 ***************
ECHO ON
stsadm -o deactivatefeature -filename "%wspname%\feature.xml" -url %2
stsadm -o retractsolution -name %1 -immediate
stsadm -o execadmsvcjobs
stsadm -o deletesolution -name %1 -override
stsadm -o execadmsvcjobs

GOTO END

:USAGE
ECHO Parameter 1 = wsp filename, for example myfeature.wsp
ECHO Parameter 2 = site, for example http://myserver:1000
ECHO Parameter 3  u or U = uninstall

:END
ECHO OFF
ECHO Done please check for errors

Wednesday, 17 February 2010

SharePoint Tools I have found useful

This is another one of those, i need to make a note of these tools and this is a “good place as any” posts.

WSPBuilder – this is the tool for creating VS.Net projects much better than VSE WSS.

SharePoint Manager (also has link to 2007 version)- This shows the SharePoint Hierarchy and allows you to do stuff

CAML Builder – because CAML is a bugger. Although do not forget to remove the <query> tag, I always do Smile

SQL Server Integration Services Adapter – For 2005 and 2008 allows you to integrate SSIS to SharePoint.

Events Manager – This allows you to see all of the EventHandlers attached to a list.

Also this blog is great for the command line on how to install / uninstall wsp files. (something I always forget).

Tuesday, 9 February 2010

Restoring and moving a content database Sharepoint 2007

For no other reason than I have had to do this a couple of times this week and I have to keep looking it up!

Restoring a database from a backup file to another database name

RESTORE DATABASE WSS_Content_ArtworksTest
FROM DISK = N'C:\test\WSS_content_artworks.bak'
WITH FILE = 1,
MOVE N'WSS_Content_Artworks' TO N'C:\Program Files\Microsoft Office Servers\12.0\Data\MSSQL.5\MSSQL\Data\WSS_Content_ArtworksTest.mdf',
MOVE N'WSS_Content_Artworks_log' TO N'C:\Program Files\Microsoft Office Servers\12.0\Data\MSSQL.5\MSSQL\Data\WSS_Content_ArtworksTest_log.LDF',
NOUNLOAD,
STATS = 10,
REPLACE
GO

Changing the contentdb.

The original one has been removed using Central Admin. AssignNewDatabaseID is because I already have this database running another site.

stsadm -o addcontentdb -url http://url:6001 -databasename wss_content_ArtworksTest -assignnewdatabaseid D8833462-FD
59-464f-89F3-55CF7AAA6206

Friday, 5 February 2010

Which IIS 7.0 Worker Process (w3wp.exe) shall I attach the debugger

 

We have all had the problem, which IIS Worker process shall I attach to when debugging. This morning I have stumbled across perhaps the easiest way of doing this!

Fire up IIS, make sure the server is selected

image

Then select “Worker Processes”

image

et Voila!, just find the Application Pool for the correct Item.