I no longer work at Microsoft, so please don't bother leaving a comment here or trying to contact me through my MSDN blog.
You can find my new blog at http://www.technologytoolbox.com/blog/jjameson. My new site also provides copies of all posts from my MSDN blog.
Last week I received a "Logical Disk Free Space is low" alert from Operations Manager for my TFS 2010 build server (DAZZLER).
"Logical Disk Free Space is low"
After a few minutes investigating the issue, I discovered that my "Builds" folder was consuming a little over 2 GB of storage. Note that DAZZLER only has a 23 GB virtual hard drive allocated to it -- which, by the time you install the Team Foundation Server Build service and Visual Studio 2010 -- doesn't have a great deal of extra capacity to begin with.
However, there's certainly no reason that I should need anywhere near 2 GB simply for storing the build output from my various sample solutions (like Fabrikam Demo and Tugboat).
I quickly identified the crux of the issue by looking at a couple of the builds for the Tugboat solution. I noticed that a recent build of the Tugboat solution was almost 76 MB on disk. If you've seen the Tugboat sample, then you should know it certainly doesn't justify this amount of disk space.
It turns out that 73 MB in each build folder was consumed by multiple copies of SharePoint assemblies, such as:
In other words, it's essentially the same problem I blogged about over a year ago -- with a slight twist.
In my earlier post, I described adding a BeforeDropBuild target to the TFSBuild.proj file in order to remove extraneous assemblies from the build. However, since I'm now using TFS 2010 build (and not using the UpgradeTemplate.xaml build process template), the TFSBuild.proj is no longer used. Hence a BeforeDropBuild target no longer does the trick.
Fortunately, the solution is very easy. I simply copied the target that I created previously and pasted it into the individual Visual Studio project files (renaming the target in the process). Instead of hooking into BeforeDropBuild (which is meaningless when compiling Visual Studio projects), I now hook into the AfterBuild target.
I think this makes more sense with an example.
Here's the corresponding pieces from my updated Web.csproj file for the Tugboat SharePoint sample:
<CallTarget Targets="RemoveExtraneousFilesFromBuild" />
<Message Importance="high" Text="Removing extraneous files from build output ($(OutDir))..." />
The following assemblies are either included in the WSPs
or else should not be included in the build
<Output TaskParameter="Include" ItemName="FilesToDelete" />
<Delete Files="@(FilesToDelete)" />
Note that I'm now using $(OutDir)-- instead of $(BinariesRoot) -- in order to remove the assemblies from the build output folders.
With this change, my Tugboat builds are now a mere 1.13 MB on disk. Woohoo!
After purging the bloated builds for the Tugboat and Fabrikam Demo solutions, I've managed to reclaim a couple of gigabytes of precious VHD space on my TFS build server.