We moved to TFS in 2009. Source control itself was a great improvement from VSS. But it became my job to manage the continuous integration process.
I remember a java project I was on where our architect set up cruise control to deliver the latest version of the nightly build to the web server every night. I want to set up something like that myself.
Setting up the build wasn't too tough. It makes a directory that contains all the products from the build in one big list. The websites themselves are in subdirectories called "_Published Websites".
First goal: how to get the build service to copy the files to the inetpub directory.
First of all, this thing is a monster. MSBuild and TFSBuild, which read the .proj files to perform builds, have their own four-hundred page instruction manual. Just trying to read this thing to get a hint of what to do is overwhelming. So I decided to start with something simple. Just copying some files after the build is done.
There seems to be more than one way of doing the same thing. I tried to do the simplest thing possible. I just wanted the build to copy the website to publish to the inetpub directory of the development web server. So I borrowed from the code listed here and added this to the end of the TFSBuild.proj file:
</ItemGroup>
<Target Name="BeforeTest">
<CreateProperty value="w:\inetpub\gavintest">
<Output TaskParameter="Value" PropertyName ="MyDropLocation" />
</CreateProperty>
<Exec Command='xcopy /y /e "$(OutDir)_PublishedWebsites\AgileGaWeb" $(MyDropLocation)' />
</Target>
Here's what this code did: It overrides the BeforeTest target. Each target is run in succession by the default build process. This code just replaces the "BeforeTest" target to inject its own action.
The first thing we do is create a property we can pass to the Exec command below. The property is "MyDropLocation", which is the path to the virtual directory.
Then we execute the xcopy command and pass it the source as a constant and the destination as the property. I already set up the directory.
Queue up the build and voila! The new app is deployed with the automatic build.
Future Topics:
Running unit tests
Variable substitution in config files
What manual are you referring to?
ReplyDeleteWe bought this:
ReplyDeletehttp://www.amazon.com/Inside-Microsoft-Build-Engine-PRO-Developer/dp/0735626286
Which, ironically, appears to have been written by you!
OK. I'm sorry to hear that you didn't have a good experience reading it. We've gotten some pretty rewally good feadback from Amazon so I thought for the most part people were satisified. If you need some help you can contact me through my blog http://www.sedodream.com.
ReplyDelete