Export (0) Print
Expand All

Walkthrough: Configuring Team Build to Build a Visual Studio Setup Project

You can customize Team Foundation Build by adding either custom tasks or by using MSBuild tasks that are executed at a specified point during the build process. This topic explains the steps that are required to customize a build definition to use MSBuild Exec task to build a Visual Studio setup project.

You need the following to complete this walkthrough:

A client computer with:

  • Development Edition installed

  • Team Explorer installed

  • An available connection to a Team Foundation Server

  • Local directory to use as your workspace

A Team Project that has:

  • A created build definition

  • A workspace for source control mapped to the local directory

    For more information, see How to: Create a Mapped Workspace. This walkthrough uses the local workspace: C:\DeploymentProjects.

  • Source Control Enabled

    1. To make sure Visual Studio is configured to use Team Foundation version control, on the Tools menu, click Options, and then click Source Control.

    2. Select Visual Studio Team Foundation Server in the Current source control plug-in list box.

A build agent with Team Foundation Build installed. 

Visual Studio must be installed on the build agent in order to use the MSBuild Exec task to call devenv.exe to build a setup project. For more information, see Exec Task and Devenv Command Line Switches.

NoteNote:

The build agent is a computer on which the builds are run. For more information, see How to: Create and Manage Build Agents.

Required Permissions

To complete this walkthrough, you must have the Administer a build and Administer workspaces permission set to Allow. You must also have the Check in and Check out permissions set to Allow.

To create a team project, you must have the Create new projects permission set to Allow, and you must be a member of the SharePoint Central Admins group in Windows SharePoint Server and have Content Manager permissions in SQL Reporting Services.

You must have install permission on the computer on which you run the installer created by Team Foundation Build.

The procedures in this walkthrough create a simple C# Windows forms application that is used as an example for configuring Team Foundation Build to build a Visual Studio setup project.

To create a Visual Studio Windows Forms application

  1. On the File menu, point to New, and then click Project.

  2. In the New Project dialog box, select Visual C# in the Project types pane. In the Templates pane, select Windows Forms Application.

  3. Type HelloWorldTest in the Name box. In the Location box, type C:\DeploymentProjects, or open the local workspace you selected for your team project.

  4. Click OK.

    HelloWorldTest appears in Solution Explorer, and the Form1.cs appears in the Windows Forms Designer.

  5. On the View menu, click Toolbox to make the list of controls visible.

  6. Drag a Button control to your form.

  7. Double-click the new button to open the Code Editor.

    Visual C# has inserted a method called button1_Click.

  8. Add the following code to the method:

    private void button1_Click(object sender, EventArgs e)
            {
                MessageBox.Show("Hello World!");
    
            }
    
  9. On the File menu, click Save All to save your changes.

  10. On the Build menu, click Build HelloWorldTest to build your solution and to verify there are no build errors.

To create a deployment project

  1. Select the HelloWorldTest solution in the Solution Explorer and on the File menu, point to Add, and then click New Project.

  2. In the Add New Project dialog box, in the Project Types pane, expand the Other Project Types node, click Setup and Deployment, and then in the Templates pane, click Setup Project. In the Name box, type HelloWorldTestInstaller.

  3. Click OK to close the dialog box.

    The project is added to Solution Explorer, and the File System Editor opens.

To add the HelloWorldTest application to the installer

  1. Select the HelloWorldTestInstaller in Solution Explorer. In the File System Editor, right-click the Application Folder node, point to Add and then click File.

  2. In the Add Files dialog box, open the location of HelloWorldTest.exe, select it, and then click Open.

    The location in this walkthrough is C:\DeploymentProjects\HelloWorldTest\HelloWorldTest\obj\Debug\HelloWorldTest.exe. Your file path may be different depending on the location of your local workspace.

  3. On the File menu, click Save All to save your changes.

  4. On the Build menu, click Build HelloWorldTestInstaller to build a local copy of the installer and to verify there are no build errors.

    To verify that the Setup project built the installer, open the output file location. You should see HelloWorldTestInstaller.msi and setup.exe in the output file location.

    NoteNote:

    To find the output file, right-click HelloWorldTestInstaller project in Solution Explorer, and then click Properties. In the HelloWorldTestInstaller Property Pages dialog box, the Output file name box contains the location of the installer files.

To modify the vdproj-file to work with Team Foundation Build

  1. Right-click HelloWorldTestInstaller project in Solution Explorer, and then click Properties. In the HelloWorldTestInstaller Property Pages dialog box, click the Configuration Manager.

    Make sure that the Build box is selected for both HelloWorldTest and HelloWorldTestInstaller.

  2. Click Close to close the Configuration Manager dialog box, and click OK to close the HelloWorldTestInstaller Property Pages dialog box.

  3. On the File menu, click Save All to save your changes.

  4. Locate the HelloWorldTestInstaller.vdproj file.

    The location in this walkthrough it is C:\DeploymentProjects\HelloWorldTest\HelloWorldTestInstaller. Your file path may be different depending on the location of your local workspace.

  5. Right-click HelloWorldTestInstaller.vdproj, point to Open With, and then click Choose Program. In the Open With dialog box, select Notepad from the Programs pane, and then click OK to open HelloWorldTestInstaller in Notepad.

  6. Verify that all the file paths are listed as relative to the location of the HelloWorldTestInstaller.vdproj files.

    There should be no absolute paths listed.

To add and check-in HelloWorldTest to Team Foundation source control

  1. Right-click the HelloWorldTest solution in Solution Explorer and then click Add Solution to Source Control.

    A yellow plus-sign appears next to all the files. This indicates that they are pending addition to source control.

  2. Right-click the HelloWorldTest solution in Solution Explorer, and then click Check In. In the Check In - Source Files - Workspace: <Workspace name> dialog box, scroll to the files that are selected. Clear the Name box for HelloWorldTest.exe and then click Check In.

    The files are now checked in to Team Foundation version control.

    Important noteImportant Note:

    Make sure you uncheck the executable because you are configuring Team Foundation Build to build a new executable.

Before you build the HelloWorldTestInstaller project by using Team Foundation Build, you must either create a new build definition, or use an existing build definition that you can modify. For more information, see How to: Create a Build Definition. You must modify the TFSBuild.proj project file that is associated with your build definition to instruct it to build the setup project.

To modify the TFSBuild.proj file to build the setup project

  1. On the View menu, point to Other Windows, and then click Source Control Explorer.

  2. In Source Control Explorer, expand your team project in the Folders pane, and locate the TFSBuild.proj file you created. The default location is in the TeamBuildTypes folder, located under your team project folder.

  3. On the viewing pane, select the build type you want to use for building HelloWorldTest and HelloWorldTestInstaller. If you do not have a copy of the file in your local workspace, right-click the TeamBuildType folder, and then click Get Latest Version.

    This action makes the files available to be checked out for editing.

  4. On the viewing pane, double-click your build type, right-click TFSBuild.proj, and then click Check Out for Edit. On the Check Out dialog box, select None- Allow shared checkout, and then click Check Out.

    A red check-mark appears next to the TFSBuild.proj file and indicates its source control status.

  5. Double-click the TFSBuild.proj file to open it in the Visual Studio XML-editor.

  6. Add the following code, in bold-type, to the end of the TFSBuild.proj file, before the closing </Project> tag.

    <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;"/> 
        <Copy SourceFiles="$(SolutionRoot)\HelloWorldTest\HelloWorldTestInstaller\Debug\HelloWorldTestInstaller.msi; $(SolutionRoot)\HelloWorldTest\HelloWorldTestInstaller\Debug\setup.exe" DestinationFolder="$(OutDir)" /> 
    </Target> 
    
    

    This uses the MSBuild exec task to build the HelloWorldTestInstaller setup project by invoking the devenv.exe program. For more information, see Exec Task. The MSBuild copy task is used to copy the .msi and .exe files to the Team Foundation Build output directory. For more information, see Copy Task.

    The AfterCompile target is executed after Team Foundation Build has finished executing the CoreCompile target, where the HelloWorldTest application is compiled. For more information about the target names, see Understanding Team Foundation Build Configuration Files.

  7. On the File menu, click Save to save your changes, and then close TFSBuild.proj.

  8. In Source Control Explorer, right-click TFSBuild.proj, and then click Check In Pending Changes. As an option, you can add a comment in the Check In - Source Files - Workspace: <workspace name> dialog box. Click Check In to check TFSBuild.proj into source control.

After you have modified the TFSBuild.proj file and saved the changes in Team Foundation version control, run the build definition to build your deployment project.

To run the team build definition

  1. On the Build menu, click Queue New Build.

  2. On the Queue Build "team project name" dialog box, select the build definition you want to use, the build agent, the priority in queue, and then click Queue.

    For more information, see How to: Queue or Start a Build Definition.

    You can monitor the build process in Build Explorer. For more information, see How to: Monitor Build Progress

  3. In the Build Explorer, click the log file under the Summary heading. Examine the log file for any errors.

    NoteNote:

    You can safely ignore the warning MSB4078: The project file "HelloWorldTestInstaller\HelloWorldTestInstaller.vdproj" is not supported by MSBuild and cannot be built. The file is built by the devenv.exe program that uses the MSBuild Exec task.

To install the generated setup file

  1. Locate the build drop location \\<drop location>\Public_build\HelloWorldTestBuild_<build number>\Release.

    The drop location is the same file share as the log file location and is listed under the Summary heading in the Build Explorer.

  2. Copy the HelloWorldTestInstaller.msi and setup.exe files to a computer where you are a member of the Windows Administrator security group or have the Install permission set to Allow.

  3. Double-click the setup.exe file and follow the instructions on the installation wizard.

    The HelloWorldTestInstaller.exe is installed under the path <root>:\Program Files\Microsoft\HelloWorldTestInstaller.

  4. Navigate to <root>:\Program Files\Microsoft\HelloWorldTestInstaller.

  5. Double-click the .exe file to run the application.

You can modify the Visual Studio Setup project to configure the installation wizard for additional steps. For more information, see Windows Installer Deployment Concepts.

Community Additions

ADD
Show:
© 2014 Microsoft