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>

Comments

  • Anonymous
    June 17, 2008
    Nikhil Singhal on Visual Studio Setup/Deployment projects and Team Foundation Server Jamie Kurtz on...

  • Anonymous
    March 10, 2009
    Hi Nikhil, I have followed the same step given by you.. unfortunately the build runs for ever.. do you have any idea.. i am really tired making vdproj/msi/setup copied into drop folder.. your advice please.. this is my configuration <Target Name="AfterCompile">    <Exec Command="&quot;C:Program FilesMicrosoft Visual Studio 9.0Common7IDEdevenv&quot; &quot;$(SolutionRoot)ADAMS R1 InstallADAMS R1 Install.vdproj&quot; /Build &quot;Release|Any CPU&quot;"/>    <Copy SourceFiles="$(BuildProjectFolderPath)/../../ACA R.5/Source/ADAMS/ADAMS R1 Install/Release/ACA R1 Install.msi" DestinationFolder="$(OutDir)"/>    <Copy SourceFiles="$(BuildProjectFolderPath)/../../ACA R.5/Source/ADAMS/ADAMS R1 Install/Releasesetup.exe" DestinationFolder="$(OutDir)"/>  </Target>

  • Anonymous
    May 06, 2009
    Thanks for the great idea!!! I added your snippet to our build script and it works fine. I am new to the whole msbuild area so this was very helpful.

  • Anonymous
    June 11, 2009
    The comment has been removed