SharePoint Solutions can be packed in a CAB file using the STSADM tool, as described in a previous post.
Whenever you need deploy or redeploy a solution on a particular environment, you have to do a bit more than just run STSADM again. Particularly, you have to:
- Delete the existing site http://www.yoursite.local
- Create a blank site at http://www.yoursite.local
- Run STSADM to import the Site Definition from the CAB file
You want to completely automate these steps and create a full provisioning process, using a script such as this:
ECHO OFF
Set cabFileName=YourSiteDefinition.CAB
set SiteName=http://www.yoursite.local
set siteOwnerEmail=administrator@yoursite.local
set siteOwnerLogin=%computername%\administrator
@set Path=C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN;%PATH%
ECHO ON
stsadm -o deletesite -url %siteName%
@Set Path=C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN;%PATH%
stsadm -o createsite -url %siteName% -sitetemplate BLANKINTERNET -ownerlogin %siteOwnerLogin% -owneremail %siteOwnerEmail%
stsadm.exe -o import -url %siteName% -includeusersecurity -filename %cabFileName%
Creating and saving this script in your Source Control server, along with the .CAB files containing your Site Definitions, allows the developer to quickly setup and provision the solution in the local development environment, as well publishing updates to test, staging and production environments.
Installing additional components
Probably, your Site Definition may use specific components, such as User Controls, Web Forms, Mobile User Forms and so on. The deployment of these components can also be automated, using a batch:
Set SharepointHive= "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE"
Set MobileControlDir=%SharepointHive%\LAYOUTS\MOBILE
Set UserControlDir=%SharepointHive%\CONTROLTEMPLATES
Set MyAssembly= MyUserControls.dll
xcopy /Y usercontrols\*.* %UserControlDir%
xcopy /Y mobilecontrols\*.* %MobileControlDir%
GACUtil /i %MyAssembly% /f
Going further
This approach works fine, but more complex solutions may require a more sophisticated deployment process, using WSP Solution packages. A good subject for a future post.
Contributors: Telmo Cruz

No comments:
Post a Comment