Helping TDS some more
A few months ago I blogged about helping TDS clean up after file replacement. Today I learned that TDS needs some more help and decided to give it a hand.
When TDS builds your TDS.Master project it goes through various steps to copy your solution files, do file replacements, perform XML config transforms, generate a package, etc. I guess what I am saying is –
HedgehogDevelopment.SitecoreProject.targets would be a good read if only it wasn’t an MSBuild XML.
The way TDS keeps track of what it does and what it will later have to clean if asked to do so is via a
BuiltFiles_$(Configuration).txt journal file in your
./bin. You will find the following task all over TDS targets:
<WriteLinesToFile File="$(MSBuildProjectDirectory)binNewBuiltFiles_$(Configuration).txt" Lines="@(SourceWebFiles->'$(_OutputPath)%(RecursiveDir)%(FileName)%(Extension)')" Overwrite="true" Condition="'$(BuildingInsideVisualStudio)' == 'true'"/>
The cleanup then becomes an easy read-and-delete:
<ReadLinesFromFile File="$(MSBuildProjectDirectory)binBuiltFiles_$(Configuration).txt" ...> <Output TaskParameter="Lines" ItemName="FilesToCleanup"/> </ReadLinesFromFile> <Delete Files="@(FilesToCleanup)" TreatErrorsAsWarnings="true" .../>
I am a big fan of automation and here at BrainJocks we have various handy command line tools that build, package, deploy, scaffold, convert, transform and just make our life easier and more pleasant. And here I am, using one of my favorite
deploy CLI harnesses and wondering how come it packages up and deploys an
App_Include configuration patch that only exists in one of my feature branches.
Long story short, I was building from the command line from a different branch earlier today and the
/t:Clean wasn’t doing what I thought it was doing because of that condition I highlighted in the code above:
Help will always be given at Hogwarts
The quick solution that I came up with right on the spot was to add the following target to my
<Target Name="BeforeSitecoreBuild"> <RemoveDir Directories="$(OutputPath)" Condition="'$(BuildingInsideVisualStudio)' != 'true' and Exists('$(OutputPath)')"/> </Target>
I don’t mind a clean output target every time I build from the command line. I actually very much prefer it this way.