Visual Studio Setup/deployment projects and Team Foundation Server

Team Foundation servers use MSBuild to build our projects. MSBuild does not support the Visual Studio Setup/Deployment projects natively. In many of today's applications it's a must to have msi based installs created via Visual Studio.
Till someone actually takes the time to build a custom task library to handle vdproj files in MSBuild, we will have to use a hack to make our vdproj files get built on MSBuild. The hack is simple. After the compilation of the main solution is done, we invoke the Visual studio command line to build the vdproj project and copy the msi and setup.exe to the appropriate output folder.
The following simple steps will get you going in the correct direction.

  1. Find your TFSBuild.proj file in TFS source control for your project. Generally, if you had selected all defaults when creating a build definition, it would reside under TFSProject/TeamBuildTypes/{Build/Release} folder.
  2. Make sure your vdproj project is part of the main solution. Or else, you could create a standalone solution with the same name as the vdproj project. Either way,
  3. Edit the TFSBuild.proj file and add the following XML snippet (generally after the <ItemGroup> node).
  4. Replace the folder and files in the snippet with your project specific paths and names. Also, in the example below, I have shown the build type to be {Release/Any CPU}. You would replace this with your build specific settings.
  5. Check this file back in and fire a build. You are good to go!!!

<!-- Hack to build setup projects using MSBuild -->

<Target Name="AfterCompile">
<Exec Command="&quot;$(ProgramFiles)\Microsoft Visual Studio 9.0\Common7\IDE\devenv&quot; &quot;$(SolutionRoot)\MyAppSetup\MyAppSetup.vdproj&quot; /Build &quot;Release|Any CPU&quot;"/>
<Copy SourceFiles="$(SolutionRoot)\MyAppSetup\Release\MyApp.msi; $(SolutionRoot)\MyAppSetup\Release\setup.exe" DestinationFolder="$(OutDir)\Setup\" />
</Target>