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.

Advertisements

No comments yet

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: