Friday, 7 November 2008

Posting Code Snippets

If you're posting code snippets on blogger.com I heartily recommend you check out this blog entry by Guogang Hu:

http://developertips.blogspot.com/2007/08/syntaxhighlighter-on-blogger.html

Thursday, 6 November 2008

MSBuild & Text Transforms

I had a couple of problems with MSBuild scripts today. If you're not overly familiar with MSBuild I found Brennan's Blog has a create tutorial on it (http://brennan.offwhite.net/blog/2006/11/29/msbuild-basics-1of7/).

Firstly, ItemGroups are evaluated when the script is initially run (or something along these lines) - which in retrospect seems completely obvious. This means that if you want an ItemGroup to contain items from a build output (i.e. MSIs) then you have to create the ItemGroup via the CreateItem task. Basically, the ItemGroup is evaluated when you call the CreateItem task.

An example:


...














...


The second problem I had to overcome today was that I wanted MSBuild to transform my T4 templates. I'm currently using T4 to generate my config files as per Oleg Sych's posting at http://www.olegsych.com/2007/12/how-to-use-t4-to-generate-config-files/. This isn't really that hard to accomplish and can be done as follows:







C:\Program Files\Common Files\Microsoft Shared\TextTemplating\1.1\TextTransform.exe
..\Construction\





















I'm also using the MSBuild Community Tasks (http://msbuildtasks.tigris.org/) in the last sample script. This is to make sure the config files that are checked out are writable. The Attrib task can be used to easily change file attributes.