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 (4)

  1. Nikhil Singhal on Visual Studio Setup/Deployment projects and Team Foundation Server Jamie Kurtz on…

  2. harikrishnan says:

    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>

  3. Bill says:

    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.

  4. Kannan says:

    When i execute the above mentioned command, i get this message

    "The files mentioned could not be loaded’.

    This then points to the vdproj file. And i have the error telling me that Team build failed. Exited with code 1

    Please help