Skip to main content

Back-End Development

Helping TDS some more

Help@1x.jpg

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.

Built Files

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" .../>

Command Line

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:

[su_note note_color=”#fafafa”]TDS doesn’t have a journal record to go by if the build was a command-line build
[/su_note]

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 TDS.Master.scproj

<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.

Thoughts on “Helping TDS some more”

  1. Great set of posts, Pavel.
    It’s fantastic to see the community using the available extension points in TDS to customize their build processes in they way they want.

    – Sean

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Brian Beckham

As a Sitecore MVP, Brian spends most of his time consulting and architecting software solutions for enterprise-level Sitecore projects.

More from this Author

Follow Us
TwitterLinkedinFacebookYoutubeInstagram