Creating a New Build

Creating a New Build

Team Foundation Build uses the concept of build types. A build type is simply the container for all the configuration information related to a build. In essence, it defines all the different parts of a particular build.

You create a new build type by using the Team Explorer window. Right-click the Team Builds node and then select New Team Build Type. This will launch the New Build Type Creation Wizard.

Specifying New Build Information

The wizard will ask a series of questions about the desired build process. After you've provided the answers, the wizard will write them out into a specific file format used by the build engine.

Naming the Build

The first step is to provide a name for the build. This is the same name that is reflected within the Team Explorer Builds node and in the build reports. Figure 23.4 shows the first page in the build type wizard.

Figure 23.4. Specifying the build type name.


Selecting the Solutions to Build

The second step involves selecting the projects that you want to be included as a part of the build (see Figure 23.5). The drop-down at the top of the wizard page is used to essentially filter the list of available projects based on a given workspace (refer to Chapter 19, "Source Control," for a discussion of workspaces). Every solution that exists in the workspace selected in the drop-down will be displayed in the list box. Checking or unchecking the individual solutions will include or exclude them from the build.

Figure 23.5. Selecting the projects to build.


Note that this page of the wizard also allows you to specify the order of the build. The order is important in cases in which there may be an order dependency between the different binaries generated between solutions. You change the build order of the solutions by using the up and down arrows next to the list of solutions.

Selecting the Build Configurations

Build configurations dictate parameters for the build such as whether this is a release or debug build, and what the target CPU platform is. You can specify multiple configurations on the third page of the wizard (see Figure 23.6); they will be built in the order shown.

Figure 23.6. Selecting the build configuration.


Providing a Build Location

Team Foundation Build will need to know which server to use as the Build server. Remember, you must have already prepared this server as a Build server by running the appropriate setup files from the Team Foundation Server install media; this will deploy the build service onto the server (which must, of course, be running before you can start a build).

The build engine will need to know where to place the build files locally on the Build server and where the build output should be published so that the team can access it. All of these parameters are captured on the Location page of the wizard, shown in Figure 23.7.

Figure 23.7. Supplying location information for the build.


Selecting Build Tests

Tests can be run as part of the build process. This next page of the build type wizard (see Figure 23.8) gathers information on which tests should be run during or after the build process. By selecting a test metadata file, you can pick and choose from among any of the tests defined within the Team Project (team project tests were covered in the preceding chapter).

Figure 23.8. Options for testing the build.


By using the bottom check box, you can elect to run static code analysis against the source files included in the build.

Confirming Your Selections

The sixth and final page of the New Team Build Type Creation Wizard (see Figure 23.9) summarizes all the build definition selections you have made.

Figure 23.9. Validating the build type information.


Clicking Finish will do two things: It will write the various build settings into an XML file called TFSBuild.proj, and it will add that XML file to the source control system within a new project that is named the same as the build.

For instance, Figure 23.10 shows two new build projects as they appear within the Source Control Explorer window. They are located under the team project node and then within a folder labeled TeamBuildTypes.

Figure 23.10. Build type files in the Source Control Explorer.


Editing a Build Type

TFSBuild.proj is an XML file used as input to the MSBuild engine. Visual Studio Team System does not offer a user interface for making changes to a build after it has been initially defined. To do this, you need to directly edit the TFSBuild.proj file.

The TFSBuild.proj Project File

Listing 23.1 shows the results of a complete sample AdventureWorks build type as it is represented within the TFSBuild.proj file. Reading through the XML, you will notice that it has captured all the major build type information categories within its individual nodes: There are nodes for storing general build, solution, configuration, location, and test option information.

Tip

You are not limited to a stock set of build tasks. It is fairly straightforward to extend any given build type with custom tasks that will run during the build process. Because a task is really just a body of code that is executed during the build, creating a new task involves writing code to implement your custom action. For information on how to extend a build using custom tasks, see the MSDN topic "Walkthrough: Extending Team Foundation Build."


The XML in the build project files is extremely well commented, and the files are fairly short. Editing a build project file is straightforward and simple. As an example, if you wanted to change the server used as the Build server, you would edit the following XML node:

<BuildMachine>NewBuildServer</BuildMachine>

Listing 23.1. Sample Build File

 

None.gif <? xml version="1.0" encoding="utf-8" ?>
None.gif
< Project  DefaultTargets ="DesktopBuild"  xmlns ="http://schemas.microsoft.com/developer
None.gif/msbuild/2003"
>
None.gif 
<!--  TO EDIT BUILD TYPE DEFINITION
None.gif
None.gif To edit the build type, you will need to edit this file which was generated by the Create
None.gif New Build Type wizard.  This file is under source control and needs to be checked out
None.gif before making any changes.
None.gif
None.gif The file is available at - $/{TeamProjectName}/TeamBuildTypes/{BuildTypeName} where you
None.gif will need to replace TeamProjectName and BuildTypeName with your Team Project and Build
None.gif Type name that you created
None.gif
None.gif Checkout the file
None.gif   1. Open Source Control Explorer by selecting View -> Other Windows -> Source Control 
None.gifExplorer
None.gif   2. Ensure that your current workspace has a mapping for the $/{TeamProjectName}
None.gif/TeamBuildTypes folder and that you have done a "Get Latest Version" on that folder
None.gif   3. Browse through the folders to {TeamProjectName}->TeamBuildTypes-> {BuildTypeName} folder
None.gif   4. From the list of files available in this folder, right click on TfsBuild.Proj.
None.gif Select 'Check Out For Editdot.gif'
None.gif
None.gif Make the required changes to the file and save
None.gif
None.gif Checkin the file
None.gif   1. Right click on the TfsBuild.Proj file selected in Step 3 above and select 'Checkin
None.gif Pending Changes'
None.gif   2. Use the pending checkin dialog to save your changes to the source control
None.gif
None.gif Once the file is checked in with the modifications, all future builds using this build
None.gif type will use the modified settings
None.gif 
-->
None.gif 
<!--  Do not edit this  -->
None.gif 
< Import  Project ="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\ v8.0\TeamBuild
None.gif\Microsoft.TeamFoundation.Build.targets"
  />
None.gif 
< ProjectExtensions >
None.gif   
<!--   DESCRIPTION
None.gif    The description is associated with a build type. Edit the value for making changes.
None.gif   
-->
None.gif   
< Description > Full daily build of all AdventureWorks components. </ Description >
None.gif   
<!--   BUILD MACHINE
None.gif    Name of the machine which will be used to build the solutions selected.
None.gif   
-->
None.gif   
< BuildMachine > VSTSb3 </ BuildMachine >
None.gif 
</ ProjectExtensions >
None.gif 
< PropertyGroup >
None.gif   
<!--   TEAM PROJECT
None.gif    The team project which will be built using this build type.
None.gif   
-->
None.gif   
< TeamProject > AdventureWorksCMMI </ TeamProject >
None.gif   
<!--   BUILD DIRECTORY
None.gif    The directory on the build machine that will be used to build the selected solutions.
None.gif The directory must be a local path on the build machine (e.g. c:\build).
None.gif   
-->
None.gif   
< BuildDirectoryPath > c:\builds\daily </ BuildDirectoryPath >
None.gif   
<!--   DROP LOCATION
None.gif     The location to drop (copy) the built binaries and the log files after
None.gif    the build is complete. This location has to be a valid UNC path of the
None.gif    form \\Server\Share. The build machine service account and application
None.gif    tier account need to have read write permission on this share.
None.gif   
-->
None.gif   
< DropLocation > \\VSTSb3\dailbuild </ DropLocation >
None.gif   
<!--   TESTING
None.gif    Set this flag to enable/disable running tests as a post build step.
None.gif   
-->
None.gif   
< RunTest > false </ RunTest >
None.gif   
<!--   WorkItemFieldValues
None.gif     Add/edit key value pairs to set values for fields in the work item created
None.gif     during the build process. Please make sure the field names are valid
None.gif     for the work item type being used.
None.gif   
-->
None.gif   
< WorkItemFieldValues > Priority=1;Severity=1 </ WorkItemFieldValues >
None.gif   
<!--   CODE ANALYSIS
None.gif      To change CodeAnalysis behavior edit this value. Valid values for this
None.gif      can be Default, Always or Never.
None.gif
None.gif    Default - To perform code analysis as per the individual project settings
None.gif    Always  - To always perform code analysis irrespective of project settings
None.gif    Never   - To never perform code analysis irrespective of project settings
None.gif    
-->
None.gif   
< RunCodeAnalysis > Default </ RunCodeAnalysis >
None.gif   
<!--   UPDATE ASSOCIATED WORK ITEMS
None.gif    Set this flag to enable/disable updating associated workitems on a successful build
None.gif   
-->
None.gif   
< UpdateAssociatedWorkItems > true </ UpdateAssociatedWorkItems >
None.gif 
</ PropertyGroup >
None.gif 
< ItemGroup >
None.gif   
<!--   SOLUTIONS
None.gif    The path of the solutions to build. To add/delete solutions, edit this
None.gif    value. For example, to add a solution MySolution.sln, add following line -
None.gif        <SolutionToBuild Include="$(SolutionRoot)\path\MySolution.sln" />
None.gif    To change the order in which the solutions are built, modify the order in
None.gif    which the solutions appear below.
None.gif   
-->
None.gif   
< SolutionToBuild  Include ="$(SolutionRoot)\adventureworks\adventureworks.sln"   />
None.gif   
< SolutionToBuild  Include ="$(SolutionRoot)\AdventureWorksExtensibilityFX\
None.gif AdventureWorksExtensibilityFX.sln"
  />
None.gif 
</ ItemGroup >
None.gif 
< ItemGroup >
None.gif   
<!--   CONFIGURATIONS
None.gif    The list of configurations to build. To add/delete configurations, edit
None.gif    this value. For example, to add a new configuration, add following lines -
None.gif        <ConfigurationToBuild Include="Debug|x86">
None.gif            <FlavorToBuild>Debug</FlavorToBuild>
None.gif            <PlatformToBuild>x86</PlatformToBuild>
None.gif        </ConfigurationToBuild>
None.gif
None.gif    The Include attribute value should be unique for each ConfigurationToBuild node.
None.gif   
-->
None.gif   
< ConfigurationToBuild  Include ="Debug|Any CPU" >
None.gif     
< FlavorToBuild > Debug </ FlavorToBuild >
None.gif     
< PlatformToBuild > Any CPU </ PlatformToBuild >
None.gif   
</ ConfigurationToBuild >
None.gif 
</ ItemGroup >
None.gif 
< ItemGroup >
None.gif   
<!--   TEST ARGUMENTS
None.gif    If the RunTest is set to true then the following test arguments will be
None.gif    used to run tests.
None.gif
None.gif    To add/delete new testlist or to choose a metadata file (.vsmdi) file, edit this value.
None.gif    For e.g. to run BVT1 and BVT2 type tests mentioned in the Helloworld.vsmdi file, add
None.gif the following -
None.gif
None.gif    <MetaDataFile Include="$(SolutionRoot)\HelloWorld\HelloWorld.vsmdi">
None.gif        <TestList>BVT1;BVT2</TestList>
None.gif    </MetaDataFile>
None.gif
None.gif    Where BVT1 and BVT2 are valid test types defined in the HelloWorld.vsmdi file.
None.gif    MetaDataFile - Full path to test metadata file.
None.gif    TestList - The test list in the selected metadata file to run.
None.gif
None.gif    Please note that you need to specify the vsmdi file relative to $(SolutionRoot)
None.gif   
-->
None.gif   
< MetaDataFile  Include ="$(SolutionRoot)\adventureworks\adventureworks.vsmdi" >
None.gif     
< TestList >   </ TestList >
None.gif   
</ MetaDataFile >
None.gif 
</ ItemGroup >
None.gif 
< ItemGroup >
None.gif   
<!--   ADDITIONAL REFERENCE PATH
None.gif    The list of additional reference paths to use while resolving references.
None.gif    For example,
None.gif        <AdditionalReferencePath Include="C:\MyFolder\" />
None.gif        <AdditionalReferencePath Include="C:\MyFolder2\" />
None.gif   
-->
None.gif 
</ ItemGroup >
None.gif
</ Project >
None.gif
None.gif

Note

To open the build project file in Visual Studio, you either right-click on the build type in the Team Explorer and select View Build Type, or navigate to the specific TFSBuild.proj file in Source Control Explorer and double-click on the filename.


The Role of MSBuild

As mentioned earlier, the core of the TFS Build server is a technology called MSBuild. This build engine is implemented in a single executable, msbuild.exe. Although MSBuild ships with Visual Studio, it does not have any dependencies on the IDE, which means you can run the file on machines that don't have the development environment installed. In fact, MSBuild may actually be distributed within future operating systems from Microsoft, such as Microsoft Windows Vista.

MSBuild works by taking in an XML file that describes the sequence of events for the build. It then processes those events in the order specified. MSBuild is a robust engine in that it can handle conditional builds, incremental builds, and dependencies between targets and builds. Because the TFSBuild.proj file conforms to the MSBuild specifications for its input file, Team Foundation Build is able to simply pass this file over for execution when the build is kicked off. In summary, Team Foundation Build overlays the MSBuild engine with a user interface and a series of functions to integrate the build into the overall fabric of the project team (thus allowing for notifications, changeset selections, and so on).


转载于:https://www.cnblogs.com/snowball/archive/2007/07/27/833766.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值