My two previous posts talked about using MSBuild tasks to move ClickOnce deployments and Reporting Services reports. In this post I wanted to show how to use MSBuild, PSExec and Linkd to set up deployments from a QA environment to a staging and finally a production environment.
PSExec allows users to execute process remotely on another box. Using PSExec you can execute Linkd on another box to create or remove junctions. A junctions is basically a pointer from one folder to another kind of like a symlink (unix). The one difference to note between junctions and symlinks is if you delete the folder that has a junction to another folder the other folder also gets deleted. In IIS you can set up a website or virtual directory to point to any folder. The folder that IIS is looking at can have a junction on it pointing to another folder.
Add in MSBuild and you get a targets like this:
<Target Name="RemoveStagedJunctions"> <Exec Timeout="15000" ContinueOnError="true" Command='$(MSBuildProjectDirectory)\bin\psexec.exe \\$(WebServer) -n 15 "c:\program files\junction\linkd.exe" $(StagedLocation) /D'> </Exec> </Target>
<Target Name="CreateStagedJunctions"> <Exec Timeout="15000" ContinueOnError="true" Command='$(MSBuildProjectDirectory)\bin\psexec.exe \\$(WebServer) -n 15 "c:\program files\junction\linkd.exe" $(StagedLocation) $(VersionsLocation)\WebSite_$(Version)'> </Exec> </Target>
The next questions is why? By having a directory that contains different versions of the application and using junctions you can simply change the junction to go between versions. If there is a problem with a release after it goes into production you can revert back to the previous version by simply changing the junction. Also by using junctions it makes moving a release to production very clean and fast. The important thing I protect against when moving from QA to a staging environment is if the application version (folder name) already exist then do not proceed with the deployment/move. Both production and QA use a specific version of the application out of a “versions” folder. The last thing I want to happen is to have the staged and production environments pointed at the same version since then staged or production would be pointed at the wrong database.
Remember Me
Powered by: newtelligence dasBlog 2.1.8102.813
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
E-mail
Theme design by Jelle Druyts