At the moment I’m doing a lot of SharePoint 2007 development and what I’m doing the most is waiting waiting …. So I tried to speed up SharePoint development in the project I’m currently working on. I will explain in a few steps how to create a solution for SharePoint the fastest way. In this example I use some SharePoint tools that you can download for free.
For this example I want to create a feature that when it is activated is changes the name of the site.
Create a C# class library and called “MySharePointSolution1” (delete the class1.cs file). It should look like this

The structure that I’m creating is used by a very handy tool called the WSPBuilder. You can download this tool at http://www.codeplex.com/wspbuilder. In the documentation for this tool you can read what sort of a structure is desired for having the WSPbuilder working. I won’t explain that here.
You can see that I created some folders that mirror the structure of the structure of SharePoint, this must be done to have the WSPBuilder tool working. I added also the “SiteNameChangeFeature” folder which contains a feature receiver code to change the site name (we look at that later). I also added a post build event that copies the dll to the GAC folder inside the VS project.
copy "$(TargetPath)" "$(ProjectDir)GAC"
The “solution” folder that I is created contains the actual solutions package for SharePoint, the “.wsp” file.
The “feature.xml” looks like this
<?xml version="1.0" encoding="utf-8" ?>
<Feature Id="6395B135-6552-45bc-A842-58900C1E553E"
Title="Site name change feature"
Description="This feature will change the name of the site"
Version="1.0.0.0"
Scope ="Web"
Hidden="false"
xmlns="http://schemas.microsoft.com/sharepoint/"
ReceiverAssembly="MySharePointSolution1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=403f4a28f90a5cfd"
ReceiverClass="MySharePointSolution1.SiteNameChangeEventFeatureHandler">
</Feature>
The “SiteNameChangeFeatureHandler.cs” looks like this
using Microsoft.SharePoint;
namespace MySharePointSolution1
{
public class SiteNameChangeEventFeatureHandler : SPFeatureReceiver
{
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
object featureParent = properties.Feature.Parent;
SPWeb site = (SPWeb) featureParent;
site.Title = "A New Title";
site.Update();
site.Dispose();
}
public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
{
return;
}
public override void FeatureInstalled(SPFeatureReceiverProperties properties)
{
return;
}
public override void FeatureUninstalling(SPFeatureReceiverProperties properties)
{
return;
}
}
Try to build the project and the “MySharePointSolution1.dll” should appear in the GAC folder in your VS project.
Next step is to add the “WSPBuilder.exe”, “CabLib.dll” (comes with the WSPBuilder) to your VS project and add another post build event .
$(ProjectDir)wspbuilder.exe -Outputpath "$(ProjectDir)solution" -WSPName "MySharePointSolution1_v0.1.wsp"
Rebuild the project. If everything went ok then the “solution” folder should now contain a “manifest.xml” and a “MySharePointSolution1_v0.1.wsp” (press “show all files in the solutions explorer”).
The next step is to install the created wsp file into our SharePoint environment. We could use the “stsadm.exe” command line utility for this but I’m using another tool for that, the “SharePoint Solultion Installer”. You can download this tool and read the usage of this tool at http://blog.mondosoft.com/ontolica/archive/2007/03/14/Generic-SharePoint-2007-Solution-Installer.aspx . When you extract the SharePointSolutionInstaller_V1_0_3.zip you get a “setup.exe” and a “setup.exe.config”. Put these two files in the “solution” folder of the VS project.
The total solution should look something like this now
Modify the “setup.exe.config” with the correct solution id and title. Mine looks like this. (Your solution id is probably different. You can find your solution id in the generated “manifest.xml” or in a file called “solution.txt” in the root of the vs. project)
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="BannerImage" value="Default"/>
<add key="LogoImage" value="None"/>
<add key="EULA" value=""/>
<add key="Require" value="MOSS"/>
<add key="SolutionId" value="93f0038b-94ec-40ef-b628-cda46bb4b5cc"/>
<add key="FarmFeatureId" value=""/>
<add key="SolutionFile" value="MySharePointSolution1_v0.1.wsp"/>
<add key="SolutionTitle" value="MySharePointSolution1"/>
<add key="SolutionVersion" value="1.0.0.0"/>
<add key="UpgradeDescription" value="Upgrades {SolutionTitle} on all frontend web servers in the SharePoint farm."/>
<add key="RequireDeploymentToCentralAdminWebApllication" value="true"/>
<add key="RequireDeploymentToAllContentWebApplications" value="false"/>
</appSettings>
</configuration>
Now you can run the setup.exe and install the solution in SharePoint. If everything went ok you should see your feature in the “site features” list.
The conclusion is that by using the “WSPBuilder” you get the advantage of not creating a “ddf” file and a “manifest.xml” . And by using the “SharePoint Solution Installer” tool you don’t have to use the stsadm.exe command line to install your solution in SharePoint.
One last thing you can do is add the following line to the post build event so that your new compiled dll is deployed directly to the “real” GAC.
"c:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\gacutil.exe" -if "$(TargetPath)"
I use another tool called the “application pool manager” you can download at http://www.harbar.net/archive/2007/04/06/App-Pool-Recycler-for-SharePoint-devs.aspx to not do a “iisreset” but only recycle the application pool, which makes the SharePoint development a bit faster.
The latest articles I read about SharePoint development are:
Development Tools and Techniques for Working with Code in Windows SharePoint Services 3.0 (Part 1 of 2)
http://msdn2.microsoft.com/en-us/library/bb530302.aspx
Development Tools and Techniques for Working with Code in Windows SharePoint Services 3.0 (Part 2 of 2)
http://msdn2.microsoft.com/en-us/library/bb530301.aspx