Continuous Integration in.net MARGIN KAWALEROWICZ CRAIG BERNTSON M MANNING Greenwich (74 w. long.)
contents preface xv acknowledgments xvii about this book xix about the authors xxii about the cover illustration xxiii T^ARrr 1. l^/f[amje IT HAJPPE^J iiii««c«ht*»*i*«m««e»««a««e»t«a»ti<»»l Understanding continuous integration 3 1.1 What does it mean to integrate continuously? 4 Defining continuous integration 4 * CI and your development process 5 Do I need to build ivith every change? 7' Overcoming team objections 8* It's all about reducing risk 10 1.2 A simple Hello World-type CI example 12 1.3 CI tools 13 Essential tools 14 * Code-analysis Testing tools 20 * Other tools 20 1.4 A project for CI: leasing/credit Calculation core 21 Calculators 26 1.5 Summary 27 tools 18 calculator 20 ix
Setting up a source control system 29 2.1 Choosing the right source control system for you 30 Benefits of source control systems 31 * Source control aspects to consider 32 2.2 Setting up a Subversion source control server 35 Installing VisualSVN Server 35 * Creating users and groups 37* Creating the repository 37 Keeping a healthy repository 39 2.3 TortoiseSVN and working with the repository 42 Subversion client: TortoiseSVN 42 * Creating a working copy 43 Committing changes 45 * Updating and committingfiles 48 Referencing 50 2.4 Setting up Team Foundation Server 53 Installing TFS 2010 53 - TFS collections 55 Using Visual Studio Team Explorer 58 * Managing TFS source control 61 * Locking and shelving 63 2.5 Summary 64 Automating the build process 66 3.1 Build automation 67 Make and its children 67* It's not an Ant 68 3.2 The Microsoft worker: MSBuild 70 First encounters with MSBuild 71* Using predefined extend an MSBuild script 73 * MSBuild Community 3.3 The happy couple: Visual Studio and MSBuild 78 Examining a project file 79* Examining the solution file 81 * Starting an MSBuild script with Visual Studio 82 3.4 Extending MSBuild by writing and using tasks to Tasks 76 custom tasks 83 Implementing a custom task 84 * Putting it all together 86 3.5 Summary 88 Choosing the right CI server 89 4.1 A quick review of the CI process 90 4.2 Examining the CI server possibilities 92 Manual integration build or your own CI server? 92 CI servers for.net 94
4.3 Continuous integration with CruiseControl.NET 95 Starting with CCNet 96 * Configuring CCNet 97 Triggering builds 100 4.4 Continuous integration with TeamCity 102 Running TeamCity 102* Configuring a project 104 Pre-tested commit 110 4.5 Continuous integration with Team Foundation Server 2010 113 TFS and build controllers 113* Configuring TFS build agents 115* TFS build configuration 116 4.6 Summary 119 Continuous feedback 120 5.1 Knowing the state of your CI process 121 5.2 ContinuousfeedbackwithCruiseControl.NET 122 The CCNet Web Dashboard 122* Gettingfeedback with CCTray 126 * Alternative feedback mechanisms with CCNet 128 5.3 Continuous feedback with TeamCity 129 TeamCity web feedback 130 * The TeamCity Windows Tray Notifier 132 Alternative notifications with TeamCity 134 5.4 Continuous feedback with Team Foundation Server 135 TFS tray notification the TFS website with TFS 137 136* Getting build details from 137* Alternative feedback mechanisms 5.5 Extending build notifications 139 Providing feedback via an LED message board 139 Providing feedback via SMS notifications 142 5.6 Summary 142 Unit testing continuously integrated 6.1 Unit testing from a bird's-eye code 144 view 145 6.2 First encounters with unit testing 146 The search for perfect unit test material 147 Testing with NUnit 149* Marrying NUnit with CruiseControl.NET 151 * Examining test coverage 154
xii CONTENTS 6.3 Microsoft unit testing framework 157 Creating unit tests the Microsoft way 157 * Testing on TFS2010 160 * MSTest in non-tfs environment 161 6.4 Summary 164 P^wAJRlT 2 jei^x.te1sidit»165 Performing integration, system, and acceptance testing 167 7.1 Extending your CI test repertoire 168 Beyond unit tests in CI 169 * Involving the customer or domain expert in the CI testing process 171 * Right timing, right failing 172 7.2 Up close and personal with integration tests in CI 173 Performing integration testing 173 * From mocking to integration testing 176 7.3 Testing the user interface 180 Testing Windows Forms with White 180* Silverlight test automation 182 Testing a web application with Selenium 185 * Integrating UI tests into the CI process 189 7.4 Acceptance testing with FitNesse 192 Preparing the FitNesse framework 192 FitNesse and CI 196 7.5 Summary 197 Analyzing the code 199 8.1 Analyzing object code with FxCop 200 Using Visual Studio Code Analysis 200 * Setting up continuous FxCop code analysis 203 * Integrating FxCop with CI servers 206 8.2 Analyzing C# with StyleCop 209 Using StyleCop 209 * Continuous StyleCop analysis 210 8.3 Custom FxCop and StyleCop rules 213 Developing a custom FxCop rule 214 * Developing a custom StyleCop rule 216 * Incorporating custom rules into the CI process 217 8.4 Extending code analysis 218 Static analysis with NDepend duplication with TeamCity 223 8.5 Summary 224 218* Analyzing code
xiii Part 3 Smooth and polish it 225 Generating documentation 227 9.1 XML documentation 228 Common XML documentation tags 228 Formatting text in XML comments 231 9.2 Sandcastle 233 Building 9.3 Summary 239 with Sandcastle 235 Sandcastle in CI 237 Deployment and delivery 240 10.1 Creating an installer for your Windows application 241 Creating a Microsoft Installer package in Visual Studio 241 Continuously creating installation files 243 10.2 Windows Installer XML toolset 244 Creating an installer using WiX 245 Automating WiX with CI 247 10.3 ClickOnce deployment 248 Creating a ClickOnce deployment 248 ClickOnce in a CI scenario 251 10.4 Web Deployment Tool 253 Visual Studio 2010 and MS Deploy 254 MS Deploy on the build server 256 10.5 Summary 258 Continuous database integration 260 11.1 What is continuous database integration? 261 11.2 Rolling your own continuous database integration 262 11.3 Continuous database maintenance with RoundhousE 264 11.4 Continuous database maintenance with Visual Studio 266 Getting started with database projects 266 * Generating test data 268 Unit testing stored procedures 271 " Putting Visual Studio database maintenance into CI 274 11.5 Summary 275
Extending continuous integration 276 12.1 Speeding up CI 277 12.2 Seven deadly sins of slow software builds 278 12.3 Scaling 12.4 Legal 12.5 Maturity Making a build script drive * your build 279 Getting rid of build-script targets'side effects 279 * Multiplying updated files 279 Pass-based builds 280 * Output in the source directory 281 Monoliths 281 Bad dependencies 282 CI 282 Build-agent theory 282 * Scaling TeamCity 283 roadblocks 287 model for CI 288 Building 289 * Deploying 290 * Testing 291 Reporting 292 12.6 Summary 293 index 295