Thông tin tài liệu
www.it-ebooks.info
PUBLISHED BY
M crosoft Press
A D v s on of M crosoft Corporat on
One M crosoft Way
Redmond, Wash ngton 98052-6399
Copyr ght © 2010 by Sayed Hash m and W am Bartho omew
A r ghts reserved No part of the contents of th s book may be reproduced or transm tted n any form or by any
means w thout the wr tten perm ss on of the pub sher
L brary of Congress Contro Number 2010940848
ISBN 978-0-7356-4524-0
Pr nted and bound n the Un ted States of Amer ca
M crosoft Press books are ava ab e through bookse ers and d str butors wor dw de For further nfor mat on
about nternat ona ed t ons, contact your oca M crosoft Corporat on off ce or contact M crosoft Press
Internat ona d rect y at fax (425) 936-7329 V s t our Web s te at www m crosoft com/mspress Send comments
to msp nput@m crosoft com
M crosoft and the trademarks sted at http //www m crosoft com/about/ ega /en/us/Inte ectua Property/
Trademarks/EN-US aspx are trademarks of the M crosoft group of compan es A other marks are property
of the r respect ve owners
The examp e compan es, organ zat ons, products, doma n names, e-ma addresses, ogos, peop e, p aces, and
events dep cted here n are ct t ous No assoc at on w th any rea company, organ zat on, product, doma n name,
e-ma address, ogo, person, p ace, or event s ntended or shou d be nferred
Th s book expresses the author’s v ews and op n ons The nformat on conta ned n th s book s prov ded w thout
any express, statutory, or mp ed warrant es Ne ther the authors, M crosoft Corporat on, nor ts rese ers, or
d str butors w be he d ab e for any damages caused or a eged to be caused e ther d rect y or nd rect y by
th s book
Acquisitions Editor: Devon Musgrave
Developmental Editor: Devon Musgrave
Project Editor: Iram Nawaz
Editorial Production: S4Car s e Pub sh ng Serv ces
Technical Reviewer: Marc H Young
Cover: Tom Draper Des gn
Body Part No X17-29997
www.it-ebooks.info
vii
Contents at a Glance
Part I Overview
1 MSBuild Quick Start . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2 MSBuild Deep Dive, Part 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
3 MSBuild Deep Dive, Part 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Part II Customizing MSBuild
4 Custom Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
5 Custom Loggers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
Part III Advanced MSBuild Topics
6 Batching and Incremental Builds . . . . . . . . . . . . . . . . . . . . . . . . . 163
7 External Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
Part IV MSBuild Cookbook
8 Practical Applications, Part 1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
9 Practical Applications, Part 2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
Part V MSBuild in Visual C++ 2010
10 MSBuild in Visual C++ 2010, Part 1 . . . . . . . . . . . . . . . . . . . . . . . 267
11 MSBuild in Visual C++ 2010, Part 2 . . . . . . . . . . . . . . . . . . . . . . . 289
12 Extending Visual C++ 2010 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317
Part VI Team Foundation Build
13 Team Build Quick Start. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347
14 Team Build Deep Dive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395
15 WorkowFoundationQuickStart . . . . . . . . . . . . . . . . . . . . . . . . 423
16 Process Template Customization . . . . . . . . . . . . . . . . . . . . . . . . . 455
www.it-ebooks.info
viii Contents at a Glance
Part VII Web Development Tool
17 Web Deployment Tool, Part 1. . . . . . . . . . . . . . . . . . . . . . . . . . . . 489
18 Web Deployment Tool, Part 2. . . . . . . . . . . . . . . . . . . . . . . . . . . . 521
19 Web Deployment Tool Practical Applications . . . . . . . . . . . . . . 545
Appendix A NewFeaturesinMSBuild4.0
(available online) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 569
Appendix B Building Large Source Trees
(available online) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 579
Appendix C UpgradingfromTeamFoundation
Build 2008 (available online) . . . . . . . . . . . . . . . . . . . . . . 585
www.it-ebooks.info
ix
Table of Contents
Foreword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xix
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxi
Part I Overview
1 MSBuild Quick Start . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
ProjectFileDetails . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Properties and Targets
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Item Metadata
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Simple Conditions
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Default/Initial Targets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
MSBuild.exe Command-Line Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Extending the Build Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2 MSBuild Deep Dive, Part 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Environment Variables
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Reserved Properties
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Command-Line Properties
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Dynamic Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Items
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Copy Task
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Well-KnownItemMetadata. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Custom Metadata
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
Item Transformations
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Whatdoyouthinkofthisbook?Wewanttohearfromyou!
M crosoft s nterested nhear ngyourfeedbacksowecancont nua y mproveour
books and earn ng resources for you. To part c pate n a br ef on ne survey, p ease v s t:
microsoft.com/learning/booksurvey
www.it-ebooks.info
x Table of Contents
3 MSBuild Deep Dive, Part 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Dynamic Properties and Items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Dynamic Properties and Items: MSBuild 3.5 . . . . . . . . . . . . . . . . . . . . . . . . 53
Property and Item Evaluation
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
ImportingFiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
Extending the Build Process
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
PropertyFunctionsandItemFunctions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
PropertyFunctions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
StringPropertyFunctions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
StaticPropertyFunctions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
MSBuildPropertyFunctions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
ItemFunctions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
Part II Customizing MSBuild
4 Custom Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Custom Task Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
CreatingYourFirstTask . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
Task Input/Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Supported Task Input and Output Types
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
UsingArrayswithTaskInputsandOutputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
Inline Tasks
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
TaskFactory
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
Extending ToolTask
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
ToolTask Methods
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
ToolTask Properties
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
Debugging Tasks
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
5 Custom Loggers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
Console Logger
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
FileLogger. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
ILogger Interface
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
Creating Custom Loggers
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
Extending the Logger Abstract Class
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
Extending Existing Loggers
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
FileLoggerBase and XmlLogger
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
Debugging Loggers
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
www.it-ebooks.info
Table of Contents xi
Part III Advanced MSBuild Topics
6 Batching and Incremental Builds . . . . . . . . . . . . . . . . . . . . . . . . . 163
BatchingOverview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
Task Batching
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
Target Batching
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
Combining Task and Target Batching
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
Multi-batching
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
UsingBatchingtoBuildMultipleCongurations . . . . . . . . . . . . . . . . . . . . . . . 177
Batching Using Multiple Expressions
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
Batching Using Shared Metadata
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
Incremental Building
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
Partially Building Targets
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
7 External Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
Exec Task . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
MSBuild Task
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
MSBuildandVisualStudioKnownError
MessageFormats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
Creating Reusable Build Elements
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204
NUnit
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206
FxCop
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
Part IV MSBuild Cookbook
8 Practical Applications, Part 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
Setting the Assembly Version . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
Building Multiple Projects
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
AttachingMultipleFileLoggers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
Creating a Logger Macro
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232
Custom Before/After Build Steps in the Build Lab
. . . . . . . . . . . . . . . . . . . . . . . 233
Handling Errors
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
ReplacingValuesinCongFiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
Extending the Clean
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
9 Practical Applications, Part 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
Starting and Stopping Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
WebDeploymentProjectOverview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246
ZippingOutputFiles,ThenUploadingtoanFTPSite . . . . . . . . . . . . . . . . . . . . 252
www.it-ebooks.info
xii Table of Contents
CompressingJavaScriptFiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254
Encryptingweb.cong . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256
Building Dependent Projects
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258
Deployment Using Web Deployment Projects
. . . . . . . . . . . . . . . . . . . . . . . . . . 260
Part V MSBuild in Visual C++ 2010
10 MSBuild in Visual C++ 2010, Part 1 . . . . . . . . . . . . . . . . . . . . . . . 267
TheNew.vcxprojProjectFile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267
Anatomy of the Visual C++ Build Process
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
Diagnostic Output
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271
Build Parallelism
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
ConguringProject-andFile-LevelBuild
Parallelism
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273
FileTracker–BasedIncrementalBuild . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279
Incremental Build
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279
FileTracker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279
Trust Visual C++ Incremental Build
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
Troubleshooting
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
Property Sheets
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
System Property Sheets and User Property
Sheets
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284
Visual C++ Directories
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
11 MSBuild in Visual C++ 2010, Part 2 . . . . . . . . . . . . . . . . . . . . . . . 289
Property Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
Reading and Writing Property Values
. . . . . . . . . . . . . . . . . . . . . . . . . . . . 289
Build Customizations
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294
Platforms and Platform Toolsets
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
Native and Managed Multi-targeting
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300
Native Multi-targeting
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300
HowDoesNativeMulti-targetingWork? . . . . . . . . . . . . . . . . . . . . . . . . . 301
Managed Multi-targeting
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301
Default Visual C++ Tasks and Targets
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302
Default Visual C++ Tasks
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303
Default Visual C++ Targets
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303
ImportBefore,ImportAfter,ForceImportBeforeCppTargets,
andForceImportAfterCppTargets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306
Default Visual C++ Property Sheets
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307
www.it-ebooks.info
Table of Contents xiii
Migrating from Visual C++ 2008 and Earlier to Visual C++ 2010 . . . . . . . . . . 311
IDE Conversion
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311
Command-Line Conversion
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314
Summary
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315
12 Extending Visual C++ 2010 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317
Build Events, Custom Build Steps, and the Custom
Build Tool
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317
Build Events
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317
Custom Build Step
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319
Custom Build Tool
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322
Adding a Custom Target to the Build
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324
CreatingaNewPropertyPage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326
Troubleshooting
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331
Creating a Build Customization
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332
AddingaNewPlatformandPlatformToolset . . . . . . . . . . . . . . . . . . . . . . . . . . 338
Deploying Your Extensions
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342
Part VI Team Foundation Build
13 Team Build Quick Start . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347
Introduction to Team Build . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347
TeamBuildFeatures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347
High-Level Architecture
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348
Preparing for Team Build
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350
Team Build Deployment Topologies
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 350
What Makes a Good Build Machine?
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351
InstallingTeamBuildontheTeamFoundation
Server
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352
Setting Up a Build Controller
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352
Setting Up a Build Agent
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355
DropFolders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359
CreatingaBuildDenition. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360
General
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360
Trigger
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 361
Workspace
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365
Build Defaults
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367
Process
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368
Retention Policy
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369
www.it-ebooks.info
xiv Table of Contents
WorkingwithBuildQueuesandHistory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371
Visual Studio
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372
WorkingwithBuildsfromtheCommandLine . . . . . . . . . . . . . . . . . . . . . 383
Team Build Security
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 388
Service Accounts
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 388
Permissions
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391
14 Team Build Deep Dive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395
Process Templates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395
Default Template
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396
Logging
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396
Build Number
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397
Agent Reservation
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398
Clean
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399
Sync
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400
Label
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400
Compile and Test
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 401
Source Indexing and Symbol Publishing
. . . . . . . . . . . . . . . . . . . . . . . . . . 404
Associate Changesets and Work Items
. . . . . . . . . . . . . . . . . . . . . . . . . . . . 407
CopyFilestotheDropLocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407
RevertFilesandCheckinGatedChanges . . . . . . . . . . . . . . . . . . . . . . . . . 409
CreateWorkItemsforBuildFailure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409
ConguringtheTeamBuildService . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409
Changing Communications Ports
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409
Requiring SSL
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 410
Running Interactively
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411
Running Multiple Build Agents
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412
Build Controller Concurrency
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413
Team Build API
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414
Creating a Project
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414
Connecting to Team Project Collection
. . . . . . . . . . . . . . . . . . . . . . . . . . . 415
Connecting to Team Build
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 416
WorkingwithBuildServiceHosts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 416
WorkingwithBuildDenitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417
WorkingwithBuilds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 419
15 WorkowFoundationQuickStart . . . . . . . . . . . . . . . . . . . . . . . . 423
IntroductiontoWorkowFoundation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423
TypesofWorkows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423
www.it-ebooks.info
[...]... ophisticated build processes which include such things as code generation, code s a nalysis, unit testing, automated deployment, etc To deal with these changes developers are no onger shielded from the build process Developers have to understand the build process l so that they can leverage it to meet their needs Back in 2005 Microsoft released MSBuild, which is the build engine used to build most... books most of the credit goes to the authors, but the o thers involved deserve much more credit than they are naturally given As an author, the most we can do is thank them and mention their names here in the acknowledgements s ection When I reflect on the writing of this book there are a lot of names, but there is one that stands out in particular, Dan Moseley Dan is a part of the MSBuild team He... of an MSBuild file, properties, targets, items, and invoking MSBuild Let’s get started Project File Details An MSBuild file—typically called an “MSBuild project file”—is just an XML file These XML files are described by two XML Schema Definition (XSD) documents that are created by Microsoft: Microsoft. Build. Commontypes.xsd and Microsoft. Build. Core.xsd These files are ocated in the %WINDIR% \Microsoft. NET\Framework\vNNNN\MSBuild... MSBuild 2.0 Since that release Microsoft has eleased two r major versions of MSBuild—MSBuild 3.5 and MSBuild 4.0 In MSBuild 3.5 Microsoft released such goodness as multi-processor support, multi-targeting, items and properties being d efined inside of targets and a few other things which brought MSBuild to where it needed to be In MSBuild 4.0 there were a lot of really great features delivered The feature... the PropertyGroup element, inside the Project element, will contain all of our properties The name of a property is the XML tag name of the element, and the value of the property is the value inside the element In this example, we have declared two roperties, AppServer and WebServer, with the values \\sayedApp and \\sayedWeb, p r espectively You can create as many PropertyGroup elements under the. .. Overview the path to msbuild.exe is already on the path The command you will be invoking to start MSBuild is msbuild.exe The basic usage for the command is as follows: msbuild [INPUT_FILE] /t:[TARGETS_TO_EXECUTE] So the command in our case would be msbuild HelloWorld.proj /t:HelloWorld This command says to execute the HelloWorld target, which is contained in the HelloWorld proj file The result of this... Build. Commontypes.xsd describes the elements commonly found in Microsoft Visual S tudio-generated project files, and Microsoft. Build. Core.xsd describes all the fixed elements in an MSBuild project file The simplest MSBuild file would contain the following: This XML fragment will identify that this is an MSBuild file All your content... branching logic Team Build 2010 leverages the formidable combination of Workflow Foundation (for build orchestration) and MSBuild (for build processes) to provide a powerful, enterprise-capable, build automation tool Team Build 2010 provides a custom Workflow Foundation service host that runs on the build ervers s that allows the build process to be distributed across multiple machines The Workflow Foundation... and Csc You can find a list of these tasks at the MSBuild Task Reference (http://msdn2 .microsoft. com/en-us/library/7z253716 aspx) We will now use the Message task This task is used to send a message to the logger(s) that are istening to the build process In many cases this means a message is sent to the l c onsole xecuting the build When you invoke a task in an MSBuild file, you can pass its input... deployment process for the first time you will wonder why you didn’t do that for all of your projects Who This Book Is For This book is written for anyone who uses, or is interested in using, MSBuild or Team Build If you are using Visual Studio to your applications then you are already using MSBuild Inside the Microsoft Build Engine is for all developers and build masters using Microsoft t echnologies . using, MSBuild or Team Build.
If you are using Visual Studio to your applications then you are already using MSBuild.
Inside the Microsoft Build Engine. Microsoft released MSBuild, which is the build engine used to build most Visual
Studio projects. That release was MSBuild 2.0. Since that release Microsoft has
Ngày đăng: 06/03/2014, 23:20
Xem thêm: Inside the Microsoft Build Engine 2nd Edition doc