Monday, October 01, 2007

Helper DLL for MSBuild

In creating a new build, I found I needed a way to set an environment variable within the MSBuild script for subsequent use by a .BAT file.  On CodePlex, I found a project called SDC Tasks Library that filled the bill and then some.  From the site:

This is the latest version of the SDC Tasks for .NET 2.0. The SDC Tasks are a collection of MSBuild tasks designed to make your life easier. You can use these tasks in your own MSBuild projects. You can use them stand alone and, if all else fails, you can use them as sample code.


There are over 300 tasks included in this library including tasks for: creating websites, creating application pools, creating ActiveDirectory users, running FxCop, configuring virtual servers, creating zip files, configuring COM+, creating folder shares, installing into the GAC, configuring SQL Server, configuring BizTalk 2004 and BizTalk 2006 etc.

This used to be on GotDotNet (RIP) but is alive and well now on CodePlex.  To use this in your MSBuild script, put something like this at the top of the script:

<UsingTask AssemblyFile="Microsoft.Sdc.Tasks.dll" TaskName = "Microsoft.Sdc.Tasks.SetEnvironmentVariable" />

When you need to use it...

<SetEnvironmentVariable Variable="MyEnvVar" Value = "$(BuildPathVar)\Bin" Target="Process"/>

The help file that comes with the .DLL is only a reference and seems to have no examples, but for some tasks, the usage is pretty clear.  As always Google is your friend for real-life examples.

No comments: