I’ve tried WSPBuilder, the Extensions, and STSDev all. They were all very useful in starting out and in simple projects. I’ve found that at least for my projects, manually writing a DDF file and using the makecab myself turns out to be far, far easier. When you start doing something that’s a little out of the ordinary, the tools can really eat your time. You end up fighting the tools automated processes rather than the code you’re suppose to be writing.
To build your deployment package, you will need to build a DDF file, or Diamond Directive File. This tells makecab what to include in your WSP, and where it should extract to.
Here is an example of a simple DDF file:
;This file is for WSP CAB Generation ;A WSS or in this case MOSS solution file is essentially a .cab file, ;use the makecab.exe tool to create the solution package. ;The makecab.exe tool takes a pointer to a .ddf file, ;which describes the structure of the .cab file. ;The format of a .ddf file is basically that ;you declare a standard header and ;then enumerate, one file per line, the set of files by where they live on disk, ;separated by where they should live in the .cab file .OPTION EXPLICIT ; Generate errors .Set CabinetNameTemplate=”MyCoolTool.wsp” .set DiskDirectoryTemplate=CDROM ; All cabinets go in a single directory .Set CompressionType=MSZIP;** All files are compressed in cabinet files .Set UniqueFiles=”ON” .Set Cabinet=on .Set DiskDirectory1=”..\..\Package” ;All file reference should be from the project root ;Files to place into the CAB Root MyCoolTool.dll ..\..\Manifest.xml .Set DestinationDir=MyCoolTool ..\..\Feature.xml .Set DestinationDir=MyCoolTool\ContentPages ..\..\ContentPages\Module.xml ..\..\..\MyCoolToolWebApp\Tool.aspx ..\..\..\MyCoolToolWebApp\Tool.aspx.cs .Set DestinationDir=ControlTemplates\MyCoolTool ..\..\..\MyCoolToolWebApp\Controls\MyCoolToolControl.ascx ..\..\..\MyCoolToolWebApp\Controls\MyCoolToolControl.ascx.cs ..\..\..\MyCoolToolWebApp\Controls\MyCoolToolControl.ascx.designer.cs .Set DestinationDir=IMAGES\MyCoolTool ..\..\IMAGES\MyCoolFeaturePicture.gif
And on your Project Properties, go to the “Build Events” tab, then the “Post build event command line:” area, and type in:
makecab /f “$(TargetDir)NameOfMy.ddf”
This should build your WSP file for you every time you compile. When you’re ready for a deploy, build some batch files to make it easy. I actually joined my retract and deploy script together so I wouldn’t have to wait on one to finish and then click to do the other. Might as well get them both overwith. My batch file:
IF [%1]== ( set APPURL=”http://localhost/” ) else ( set APPURL=”%1″ ) @set PATH=C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN;%PATH% stsadm -o deactivatefeature -name MyCoolTool-url %APPURL% -force stsadm -o retractsolution -name MyCoolTool.wsp -immediate -url %APPURL% stsadm -o execadmsvcjobs stsadm -o deletesolution -name MyCoolTool.wsp -override stsadm -o execadmsvcjobs stsadm -o addsolution -filename MyCoolTool.wsp stsadm -o execadmsvcjobs stsadm -o deploysolution -name MyCoolTool.wsp -url %APPURL% -immediate -allowCasPolicies -allowgacdeployment stsadm -o execadmsvcjobs stsadm -o activatefeature -name MyCoolTool-url %APPURL%
That’s it for deployment. Of course configuration is another issue (manifest, elements, feature xml files), but that’s another post!