How to Build Setup and Deployment Projects with Team Build

- J.D. Meier, Jason Taylor, Alex Mackman, Prashant Bansode

Team Build does not support setup projects by default. Use a custom post-build step to compile the setup project and copy the binaries to the build drop location as follows.

1. Test the build.
Make sure that the Team Build that you want to use for the setup project works. If it does not, fix it before moving on.

Tip: Most builds include the main project build as well as the setup build. If you are creating a new team build for the setup project only, do this before moving to step 2.

2. Ensure that the setup project is built by default.
  1. In Solution Explorer, right-click the installer project for which you need to create a team build.
  2. Click Properties.
  3. Click Configuration Manager...
  4. Select the build configuration(s) you want to build; for example, Debug, Release.
  5. Select the Build check box for the installer project.

3. Ensure that all build paths in the project file are relative.
  • Open the solution folder for the installer project.
  • Open the .vdproj file in an editor other than Visual Studio.
  • Check out the .vdproj file for editing.
  • Search for each of the following entries: SccLocalPath, SccAuxPath, OutputFileName, and SourcePath.
  • Ensure that the path for each entry is relative and not absolute. (This is the default when a setup project is created.) Absolute paths start with a drive letter. Relative paths start with a double forward slash (‘\\’) or nothing.
  • If you find an absolute path, replace it with a relative path. Do not modify any constant expressions. These are expanded by the installer later; for example:

"OutputFileName" = "8:c:\\temp\\SetupProject.msi" would be replaced with "OutputFileName" = "8:debug\\SetupProject.msi"

Tip: Relative paths will be directly off of the project folder.

Tip: Always use double forward slash ( '\\' ) when creating paths because it will be passed through code that decodes to a single forward slash ( '\' ).
  • If you had to make any changes, check the .vdproj file back in.

4. Add a post-compile task to your team build.
  • Open the team build you want to use for the setup project.
  • Check out the build type from source control:
    • You can find the build type beneath your team project in source control, in a subfolder of the TeamBuildTypes folder named TFSBuild.proj.
    • You might need to perform a Get Latest Version operation on the folder first.
  • In Source Control Explorer, double-click TFSBuild.Proj to open it.
Note: Viewing the build type from the Team Explorer will not work; because this opens a read-only copy of the build file.
  • Add the following code to the end of the file between the last </ItemGroup> tag and the last </Project> tag:
	<Target Name="AfterCompile">
		<Exec Command="&quot;C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\devenv&quot; &quot;C:\Documents and Settings\darren\My Documents\Visual Studio 2005\Projects\HelloWorldTest\HelloWorldTestInstaller\HelloWorldTestInstaller.vdproj&quot; /Build &quot;Debug&quot;"/>
		<Copy SourceFiles="C:\Documents and Settings\darren\My Documents\Visual Studio 2005\Projects\HelloWorldTest\HelloWorldTestInstaller\Debug\HelloWorldTestInstaller.msi" DestinationFolder="$(OutDir)" />
		<Copy SourceFiles="C:\Documents and Settings\darren\My Documents\Visual Studio 2005\Projects\HelloWorldTest\HelloWorldTestInstaller\Debug\setup.exe" DestinationFolder="$(OutDir)" />
	</Target>
  • Check the paths in the pasted code to make sure that they are accurate for your build server.
Tip: Use the command line to test the path in the exec command tag. Replace each &quot; with a quote when testing on the command line, for example:

"C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\devenv" "C:\Documents and Settings\darren\My Documents\Visual Studio 2005\Projects\HelloWorldTest\HelloWorldTestInstaller\HelloWorldTestInstaller.vdproj" /Build "Debug"

Tip: Use the command line to test the SourceFiles paths as well.

5. Test the build changes.
  1. In Team Explorer, right-click the build type and then click Build Team Project.
  2. Review the build summary to determine if the build passed or failed.
  3. If the build failed, click the link to the build log. Common reasons for failure include:
    1. Exec command path is incorrect.
    2. Permissions are not set to allow the output files to be copied to the build directory. Make sure that the tfsservice user account has permissions to copy from the binaries folder and to the build folder. The binaries folder is the location where the msi file will be placed after the solution builds. The build folder is specified in tfs.proj in the <BuildDirectoryPath> tag.
    3. Permissions are not set to allow the installer to build. Make sure that the tfsserver user account has permissions to read the .vdproj file and source files for your installer project as well as the application with which the installer is associated. Also make sure that the tfsserver user account has permissions to write binary files to the output directory; for example, Debug or Release.
    4. Build configuration is incorrect. Make sure that the build configuration you specify in the exec command exists for your project. For instance, your project might have "Debug|Any CPU" but not "Debug". You can check this by looking at the solution properties in Solution Explorer.
  4. If the build log does not give you enough information, create an output file for the exec command and review this log for more information. For example:

<Exec Command="&quot;C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\devenv&quot; &quot;C:\Documents and Settings\darren\My Documents\Visual Studio 2005\Projects\HelloWorldTest\HelloWorldTestInstaller\HelloWorldTestInstaller.vdproj&quot; /Build &quot;Debug&quot; > c:\temp\output.txt"/>

Additional Resources

Last edited Jul 26, 2007 at 7:09 AM by prashantbansode, version 1

Comments

No comments yet.