A Failsafe For non-Debug TDS Builds

Posted 09/15/2011 by techphoria414

Posted in

Another advantage of Team Development for Sitecore is that deployment to your various environments can be configured as part of the Solution's Build Configurations, allowing you to easily deploy either right from your desktop or as part of an automated build process. The side effect of this is that if you don't remember switching to say, your QA server's build configuration, you can easily deploy in-progress code to an environment that's not your local machine. (I will not confirm nor disconfirm I've done this.) Though you probably don't want your production environment fully configured in TDS anyway, even a deploy to a QA or UAT server would be enough to get someone knocking on your door asking why "everything is broken."

We put together a quick failsafe to prevent this. You'll need to install the MSBuild Extension Pack. The example below assumes v4.0, x86. If the build is running in Visual Studio, and is anything other than a Debug build, a confirmation dialog appears that requires you to type in a super secret password before the build will continue. To add to your build, unload your TDS project, edit the .csproj, and paste in, perhaps near the bottom of the project config.

    <Import Project="$(MSBuildExtensionsPath)\ExtensionPack\4.0\MSBuild.ExtensionPack.tasks" />
    <Target Name="BeforeSitecoreBuild">
        <CallTarget Targets="ConfirmNonDebugBuild" Condition="'$(BuildingInsideVisualStudio)' == 'true' And '$(Configuration)' != 'Debug'"/>
    <Target Name="ConfirmNonDebugBuild">
        <MSBuild.ExtensionPack.UI.Dialog TaskAction="Prompt" Title="Confirm Build" Button2Text="Cancel" Text="Type 'whiskey' below to confirm build to $(Configuration)">
            <Output TaskParameter="ButtonClickedText" PropertyName="Clicked"/>
            <Output TaskParameter="UserText" PropertyName="Typed"/>
        <Message Text="Button Text: $(Clicked) / Text: $(Typed)" Importance="high"/>
        <Error Condition="$(Clicked) == 'Cancel' Or $(Typed) != 'whiskey'"/>


Pre-Disqus Comments

  • Sean Holmesby's gravatar Sean Holmesby said:
    1/6/2012 10:03 PM

    Hi Nick, Great post. I'm fairly new to TDS, and I was wondering how you have configured your various environments in TDS? I assume you mainly mean the settings for Sitecore Deploy Folder, and the Sitecore Web Url? If so, do you have the Deploy Folder set to a location on a certain IP address? i.e a QA config with\d\qa\website (if that's even possible?) With our setup, we build the QA site on a build server, then use xcopy to copy over the built files to the QA server. Because the build occurs first, the Sitecore changes are pushed first, then the built project is copied over. I've got the feeling that this isn't ideal, and there is a better way. The way we have it, the Sitecore Deploy Folder is set to a location on the build machine (D:\jenkins\project_build\qa\website). This means that if someone accidentally builds the QA config locally, it will jut build the files to their local machine at that location, however I assume it would still push their TDS changes to the QA server (as specified in the Sitecore Web Url). Am I on the right track with my assumptions? Can you suggest ways that we can improve our process? Cheers, Sean