Archive for the ‘msbuild’ Tag

MSBuild: Conditions and Transforms

Just a quick post about something neat discovered with MSBuild.

I have a task that is building an ItemGroup which contains a whole bunch of paths that point to different kinds of projects to build. These files contain dotNet sln and VB6 vbproj files. I want to build the sln files with MSBuild and use a MSBuild extension task that wraps the VB6 IDe to build the vbproj files. To do this, I set a condition on each build task that checks the extension like so:

<MSBuild Condition=”@(FilesToBuild->’FilePattern%(Extension)’) = ‘FilePattern.sln'” …/>
<VB6 Condition=”@(FilesToBuild->’FilePattern%(Extension)’) = ‘FilePattern.vbproj'” …/>

And Voila! When the build script runs, VB6 projects are built using the VB6 task, and dotNet projects are built using the MSBuild task.

MSBuild: Custom Task MetaData

Been working with CruiseControl.Net to connect to our CMSynergy source control for some continous integration goodness. While configuring CCNet, I’ve had the oppurtunity to spend some more time with MSBuild – which always makes for some interesting times.

I plan on posting more info once this round is over, but I wanted to make a note about custom tasks from MSBuild. The setup for this, is that I am using a custom task to parse some input files based  on how the release is being defined – and then output the files that should be included in the final install package. Without going too much further into detail, the intial condition was that if this is a .0 release, all files are returned.
The task xml looked like:
<CustomTask SourceFiles=”@(SourceFiles)” Release=”$(ReleaseCondition)”>
<OutPut TaskParameter=”PublishFiles”  ItemName=”OutFiles”/>

The interesting bit to note here, was that just setting the output property to the input property (PublishFiles = SourceFiles) – ended up with the MetaData RecursiveDir on PublishFiles being reset  once the output was set to a new variable OutFiles. To get around this, I ended up setting a new custom metadata on the PublishFiles property that copies the RecursiveDir property from SourceFiles.