Share via


Building VS deployment project(MSI) with team build

You might have a requirement where you need to create a MSI for your project and distribute to the customers.

Team build does not support the creation of MSI directly due to the file system of .vdproj can not be understood by MSBuild. But you may give it a try to create one with some tweaking with your project and .proj file of team build type.

Here is the msdn article which speaks about the same:

https://msdn.microsoft.com/en-us/library/ms404859(VS.80).aspx

There are lots of other articles also, just to add my 2 cents here on how you can move while using team build for building visual studio deployment project:

1) First make sure you are able to build visual studio setup and deployment project properly with visual studio.

2) Now to get the understanding of building deployment project with team build, perform the steps mentioned in the above article on one test project rather than performing everything  directly on your main project, reason is same as you always get while developing an application, not to mess up the main project :).

3) Once you are done successfully with the sample application, add the below code in .proj file for your team build definition.

    <Target Name="AfterCompile">
    <Exec Command="&quot;$(ProgramFiles)\Microsoft Visual Studio 9.0\Common7\IDE\devenv&quot; &quot;$(SolutionRoot) \HelloWorldTest\HelloWorldTestInstaller\HelloWorldTestInstaller.vdproj&quot; /Build &quot;Debug|Any CPU&quot;"/> 
    </Target>

      (Change the "HelloWorldTestInstaller" with your project name)

   a) Here we are just calling devenv.exe with the target which will build the .vdproj after compiling the main application.

   b) You would require the full installation of visual studio, not only the components which gets installed with team explorer and team build, otherwise deployment project build will fail.

   c) If you are copying the dlls to some custom folder rather than the bin folder, then you need to set it to "PostBuildEvent" for the project's build event.

      Right click the project properties --> Build Events

      Here you need to mention the path, it will look like this:

      Copy $(TeamBuildOUtDir)\bin\debug $(SolutionRoot)\library\   (So here i am putting the dlls from debug folder to library folder). 

   d) MSI will not be copied to drop location by default, it will be in the bin\debug or bin\release or library as mentioned above. So you need to copy the MSI to drop location by mentioning the below line of code:

     <Copy SourceFiles="$(SolutionRoot)\HelloWorldTest\HelloWorldTestInstaller\Debug\HelloWorldTestInstaller.msi" DestinationFolder="$(OutDir)" />

   e) Also as you might be aware, if you don't want to copy the dlls to drop location as you are already having MSI of your project with you. Here is what you need to define in the .proj file:

      <SkipDropLocation>True<\SkipDropLocation>

   f) You may get some problem of references, to correct them, check the build order of your project, library. It should be in proper order. The way MSBuild build the project is bit different from the way visual studio build the project.

Hope this article would be of some help or give you some idea when creating MSI for your project with team build.

Disclaimer: This is a personal weblog. The opinions expressed here represent my own and not those of my employer.