I stumbled upon a nice task in MSBuild that you can use to create an executable file to
install prerequisites for your application. I used to do this in the past with by just creating a Setup Deployment project setting prerequisites and holding onto the generated .exe
The biggest problem with that was that it made it problematic to ship an installer with the version number in the filename since the setup.exe was bound to an msi filename.
Using the GenerateBootstrapper task I can create this setup.exe file as part of my build process.
Take a look at this snippet from one of my build files
Microsoft .NET Framework 3.5
Microsoft SQL Server Express 2005 SP2
WIndows Installer 3.1
The BootstrapperFile items define my prerequisites. The easiest way I found to see what the list of available prerequisites are was to create a Setup Deployment project and configure them, then look at the generated project file
Then all I need to do is invoke the task and boom, setup.exe is produced.
One thing I did run into when doing this is that you have to make sure MSBuild is using the 3.5 ToolsVersion or it won't find the merge modules.
Also, the referenced prerequisites seem to only get installed with Visual Studio so I had to install it on my build server.