It’s pretty common to have a bunch of existing tools to include in a build process, and it can be rather a pain to hand-write classes to wrap each of them as proper MSBuild tasks. As we worked on converting the Visual Studio source code to build with MSBuild we realised it would be super helpful to have some sort of tool to assist in writing those wrapper tasks.
As good fortune would have it we had an awesome intern working in the MSBuild team last summer, and she wrote a nifty application to help with this process. The application is called TaskGenerator, and it lets you describe a command-line tool with XML, then it’ll generate the appropriate MSBuild task source code that wraps the tool. Here’s an example of what the XML for regsvr32.exe looks like:
<task name=“RegisterDll“ prefix=“/“ toolname=“regsvr32.exe“ xmlns=“http://schemas.microsoft.com/developer/msbuild/tasks/2005“>
<Parameter name=“Unregister“ type=“boolean“ switch=“u“/>
<Parameter name=“Silent“ type=“boolean“ switch=“s“/>
<Parameter name=“CallDllInstall“ type=“boolean“ switch=“i“ separator=“:“ argumentparameter=“CommandLine“>
<Parameter name=“CommandLine“ type=“file“/>
<Parameter name=“Dll“ type=“file“ required=“true“/>
When you run this through the tool you get a registerdll.cs file that implements a ToolTask, and can be compiled into a custom task.
We were hoping that this tool would be our first post to the new GotDotNet site, but they’ve had a few complications during their upgrade. Rather than wait, we’re making it available now as a technology preview [download here]. We’re using the new Microsoft Community License for the release, and while there’s no source code for the tool at the moment we will change that sometime during November. This release was built against build 2.0.50727 of the .NET Framework, and will not work against earlier releases.
Note that this release is a technology preview. As with all MSBuild projects it was built using test-driven development and unit tests. However, it has not undergone a complete verification by our test team. To the best of our knowledge it is stable, but as you play with it you may find the occasional bug, area where the XML schema is limiting, or errors in the documentation. In addition, since it is a technology preview, there is no guarantee that future versions will honour XML used by this release of the tool. It is highly likely that we will modify the XML schema based on feedback from customers, and the next release of the tool will not include any code for backwards compatibility. Any XML files you create with this technology preview will only ever work with this release of the tool, build 188.8.131.52.
Enjoy, and as always send feedback to email@example.com!
[ Author: Neil Enns ]