Monday, July 28, 2008

MsBuild and Installer Projects

I remember the first time I tried msbuild. I read about it and then found out that it can actually work with the VS generated solution files. Great. Seemed easy enough. But when I tried it, I got something like the following:

Project "C:\ZenUtils.sln" on node 0 (default targets).
Building solution configuration "DebugDefault".C:\ZenUtils.sln : warning MSB4078: The project file "ZenUtilsSetup\ZenUtilsSetup.vdproj" is not supported by MSBuild and cannot be built.


Hmmmmn. Not good. The short of it is the developers of msbuild never took into account Installer projects (.vdproj files). While this may change in the future, for now this is what we have. Unfortunately, it also takes msbuild out of the picture as the one-step master builder. You will need to run a solutions containing installer projects separately with devenv.com. Yes, this is a cumbersome step.

To minimize using devenv and maximize using msbuild, I do the following:

  • Create 2 solutions. One is for my compiled components and the other is for my installer project(s)
  • In the installer project, I manually add the compiled components back in, instead of using the project outputs. I lose some project references in the installer project, but as I found quarky in the first place, it wasn't really a loss.
  • I also manually add back in needed merge modules. In my case, Microsoft_VC80_CRT_x86.msm for the common c/c++ runtime and Microsoft_VC80_MFC_x86.msm for MFC support and their associated policy files.
  • Then I include the following tasks in my nant build file:

<target description="msbuild" name="MsBuildCompile">

    <echo message="Building Binaries">

   <msbuild project="..\..\Src\ZenUtils.sln">

        <arg value="/property:Configuration=Release">

        <arg value="/t:Rebuild">

</target>

<target name="BuildMsi">

    <exec

        program="devenv.com"

        basedir="C:/Program Files/Microsoft Visual Studio 8\Common7/IDE"
        workingdir="..\..\Src\Product"

       commandline="ZenUtilsInstaller.sln

         /Rebuild Release">

    </exec>

</target>

No comments: