I have an interest in msbuild this week. I'm cleaning up a lot of extremely complex build scripts. Digging in surprises me with how much it can do - msbuild is sort of a hidden feature of .NET programming in itself.
In the SO convention that questions must have answers, in a few days or a week, I'll mark the most useful or coolest hidden feature(s) as accepted.
let bestAnswer suprise slick useful = (surprise + slick + 2*useful)
Definition of useful: I'm updating existing msbuild scripts that: package (zip files) websites and utilities, CC.NET integration, launch tests (UT + selenium), build databases. I'm adding (new targets, even more useful): deploy to VMWare virtual servers, chained builds (fast build immediately, queue slow tests). If you refer to an external library (like MSBuild community tasks), it would be nice to know how to get it.
Some msbuild surprises I've already found.
- Hello world using the Message task and Properties.
- Using msbuild as an installer for an extremely complex server product. MSB community tasks managed IIS server setup. The WriteLinesToFile and XmlUpdate tasks wrote server specific configuration files. If you've work with MSI, you'll know that anything is better than MSI for installation.
- For newbies: CSProj and Vbproj files are the same as msbuild "proj" files. To edit directly: Unload your csproj or vbproj, then right click project and select edit. This is nicer and more powerful than working with clunky pre-build / post-build events.
- MSBuild comes with the generic .NET installation. Unlike other fancy tools, you can use it on a totally clean server / desktop.
Here is msbuild Hello World After I wrote it, I found the MSDN hello world.
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build;Test" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Who>World</Who>
</PropertyGroup>
<Target Name="Hello">
<Message Text="Hello, $(Who)" Importance="high" ></Message>
</Target>
<Target Name="Build" DependsOnTargets="Hello"/>
<Target Name="Test"/>
</Project>