Over the last couple of work days I’ve been conjuring up a build task to package up the files required to deploy a sharepoint feature. Most of my work was driven via Doug Perkes blog post. The post covers a lot of the little things that are required when using the makeCab utility to generate a WSP file for deployment however I slightly altered the reg ex replacement he does to add the required assemblies into the definition file. My changes to his process are: Where he tells you to replace all the hard coded paths to your assemblies with a reg ex recognisable string I remove all hard coded paths and only provide a single place marker. e.g.
Then I define an item group outside of the sharepoint feature build target with the following:
<ItemGroup> <Assemblies Include="$(OutDir)\*.dll" /> </ItemGroup> Once the item group is defined I define a property that concatenates the assemblies into a correctly formatted string for use in the definition file using CreateProperty as so
<CreateProperty Value="@(Assemblies->'%22$(OutDir)%(FileName).dll%22 %22%(FileName).dll%22', '%0D%0A')"> <Output TaskParameter="Value" PropertyName="OutputAssemblies"/> </CreateProperty>
<FileUpdate Files="WSPBuild\WorkingSolution.DDF" Regex="#AssemblyFilePath#" ReplacementText="$(OutputAssemblies)" />
I also added a delete files task onto the end to clean up the working definition file. This can be commented out during debug so that you can inspect the file if required, but it’s a nice to have on the build server.