News



Building a MSI/Setup project using MSBuild/Team Build

Update: This can be accomplished with the MsBuild Extension Pack using the MsBuild.ExtensionPack.TFS.DevEnv

Team Build is great for building Projects applications such as Windows or Web apps.  However it is not able to build Install packages.  Because of this you have to use the Visual Studio build command line option, and copy the .msi and setup.exe files out of the local build directory.  My builds usually copy the built files from to a stage or production server, However this is difficult to do, as no TB/MSbuild variables correctly reference the local build location.  To build a visual studio setup project, I did the following:

  1. Enable building in the Solution configuration manager.  Select the configuration manger, checked build next to the Install project name. 
  2. Open the ApplicationSetup.proj file in a text editor. Searching for ProjectOutput, SourcePath, I confirmed the path was relative to the project file (..\\obj\\Release\\HelloWorld.exe) rather then literal (C:\HelloWorld\obj\\Release\\HelloWorld.exe).
  3. Modified the Build project, adding the build target type

    <Target Name="AfterCompile">

        <Exec Command=
        "&quot;$(ProgramFiles)\Microsoft Visual Studio 9.0\Common7\IDE\devenv&quot;
        &quot;$(BuildDirectory)\HelloWorld\HelloWorldInstall\HelloWorldSetup.vdproj&quot;
        /Build
    &quot;Release|Any CPU&quot;"/>
    </Target>

  4. Created a target to copy the files.  Unfortunately, the built executables are not copied to the drop location.  Their is no TFS build variable that represents the build location.  To copy the files, I had to use a literal path to the build location.  The files were referenced as "C:\build\HWBuildLoc\..." instead of $(SolutionRoot). The MSDN documentation suggests using $(SolutionRoot) to get the local build location, however this returns the incorrect directory. 

    <Target Name="AfterDropBuild">

        <Time Format="yyyyMMdd_HHmmss">

            <Output TaskParameter="FormattedTime" PropertyName="BuildDate" />

        </Time>

     

        <!-- Copy files to Stage -->

        <CreateItem Include="\\StageServer\HelloWorld_$(BuildDate)">

            <Output PropertyName="BuiltProjectStagePath"
           
    TaskParameter="Include" />

        </CreateItem>

     

       

     

        <CreateItem Include=
           
    "C:\build\HWBuildLoc\HelloWorld\HelloWorldInstall\Release\**\*.*" >

            <Output ItemName="FilesToCopy" TaskParameter="Include" />

        </CreateItem>

        <!-- Copy installer -->

        <Copy SourceFiles="@(FilesToCopy)"

             DestinationFiles=
             "@(FilesToCopy ->'\\StageServer\StageDirecoty\%(RecursiveDir)%(Filename)%(Extension)')"

             ContinueOnError="true"/>

    </Target>

  5. This does cause the application to be built twice: once through the normal build process, and again by the visual studio command line call. 

I referenced the following:

  1. Team Build target map
  2. Team Build Property Reference by Aaron Hallberg
  3. Walkthrough: Configuring Team Build to Build a Visual Studio Setup Project
Monday, March 02, 2009 10:43 AM

Feedback

# re: Building a MSI/Setup project using MSBuild/Team Build

Great post, helped me a ton. Figured I'd pass along something I figured out. I hated the idea of modifying the solution to build the setup project since this is just for the automated builds... sooo I modified the command line call as follows:


C:\Program Files\Microsoft Visual Studio 9.0\Common7 IDE>devenv "...\SomeSweetSolution.sln" /build "Release|Any CPU" /project
"...\VeryCoolDeployment.vdproj"

Hope you find this helpful, thanks for all your help!
12/16/2009 12:42 AM | James W. Shumaker

# re:

Occur Used,later enough pass female fit encourage his implication develop but vision equipment context block tiny unit exchange origin attempt dangerous sign everybody negotiation just vision clearly complete video teach library pick down permanent thanks smile capacity old smile client whatever summer able next hate young cup excellent obtain favour police negotiation risk criticism faith spring kind hour regulation hotel importance yourself appearance black discuss blow nose program start them distinction introduction high conservative substantial detailed act treatment military range it provide lay front district last weight date side library understand 1/29/2010 2:55 PM | hotel tuerkei buchen

Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification: