Go back

Speeding up deployment by zipping drop files in TFS

As most of the projects we produce are web based, we use the file copy feature of ASP.NET heavily. It makes for wonderfully simple deployment. Using this feature does however mean that we zip the files up before sending them over to the live server.

To speed up deployment even further, we added a zip command to our build job in Team Foundation Server Build that zips the files in the drop location, ready for copy.

Zipping is not supported out of the box in TFS but the MSBuild Community Tasks Project has a lovely one.

To use the zip command in the community tasks library you need to add a reference to it.

<span style="color: #0000ff">&lt;</span><span style="color: #800000">Import</span> <span style="color: #ff0000">Project</span><span style="color: #0000ff">=&quot;$(MSBuildExtensionsPath)MSBuildCommunityTasksMSBuild.Community.Tasks.Targets&quot;</span><span style="color: #0000ff">/&gt;</span>
Once this has been imported you can then use the zip command in your script. We tend to use the zip command in the AfterDropBuild event.
<CreateItem Include="$(DropLocation)$(BuildNumber)Release***.*" Exclude="$(DropLocation)$(BuildNumber)Release***.config">
<Output ItemName="ZipFiles" TaskParameter="Include" />

<Time Format="yyyy-MM-dd">
<Output TaskParameter="FormattedTime" PropertyName="buildDate" />

<Zip Files="@(ZipFiles)" WorkingDirectory="$(DropLocation)$(BuildNumber)Release" ZipFileName="$(DropLocation)$(BuildNumber)NBR Release $(buildDate).zip" />

We also tend to put the date into the release and we do that by using the Time command. This now gives us a prepped zip file with all the release files in it.

Got a project? Let's work together

Compsoft is a remote working company except for Thursdays when we work together from the Alton Maltings in Alton, Hampshire (UK). Our registered address is detailed below. We'd be delighted to have either a virtual chat with you or to make arrangements to meet in person.