Creating MSBuild XSD schemas for your custom tasks

Share on:

Update 12/10/2012 - Since the LSS website is no longer active, I’ve moved the download to this site.

I’ve just uploaded a little utility onto our website herethe downloads section on this site that should help those developers that write their own MSBuild tasks.

One of the nice features that’s a little hidden in Visual Studio is its ability to provide IntelliSense and auto-completion for XML files based on the schemas that they reference, as long as the reference XSDs are included in {ProgramFiles}\{MicrosoftVisualStudioFolder}\Xml\Schemas\1033. MSBuild scripts are XML, and as such it’s possible to provide information about custom tasks that you’ve written - the only problem is that whilst writing XSD schemas isn’t exactly difficult, it can be quite involved if there are a lot of tasks that you want to expose, and keeping them in sync with your code as it changes over time can be a pain.

Enter the LSS MSBuild Schema Generator, or MSBuildSchemaGen for short. This takes one or more assemblies that contain MSBuild tasks and generates the XSD and tasks reference file (i.e. the file that contains all the UsingTasks declarations) for them. If you’ve documented your tasks in code and compiled your DLL with XML documentation, MSBuildSchemaGen will even annotate the schema with your documentation, enabling even richer IntelliSense.

MSBuildSchemaGen can be used from a simple command line utility, or integrated into your build process with the provided MSBuild task. (yes, the XSD and tasks files are generated by MSBuildSchemagen itself!)

What’s really nice about all of this is that MSBuildSchemaGen is free for you to use right now, so get it from herehere and let me know how you get on.