All Sayed all the time (and MSBuild)


All Sayed all the time (and MSBuild)

  • Comments 11

In the February 2009 MSDN Magazine, in Part 1 of a two-part article, Sayed Ibrahim Hashimi discusses “best practices that developers should follow when using MSBuild, the Microsoft build engine used by Visual Studio to build managed projects.”

Sayed’s 432-page Inside the Microsoft Build Engine: Using MSBuild and Team Foundation Build, written with William Bartholomew, was also published this month by Microsoft Press and is available now.

Inside the Microsoft Build Engine cover

The book’s Foreword is by fellow Microsoft Press author (among other things) Richard Hundhausen:

Foreword

Automated build systems are the workhorses of the software development team. They tirelessly do what they are told. They get. They clean. They build. They rebuild. They copy. They deploy. They test. And they don’t judge those who break the build. Without emotion, they just do what they are told. We can’t live without them.

The problem is that an automated build system such as this can be more difficult to construct than the underlying application the team really cares about. Why is this? From my experience, it’s caused by several factors. MSBuild is not widely understood and is quite complex. There are no IDEs that support a visual “drag and drop” editing and debugging experience. Most teams don’t have a dedicated “build master” to learn this new language and wrangle all of those angle brackets. As a result, scripts are located on the Web and spliced together to make something that works without the editor really understanding what’s going on. This is unacceptable.

When Microsoft first introduced MSBuild with .NET 2.0, it was without a bang. This stealthy feature surfaced only when you tried to open a Visual Studio 2003 project in Visual Studio 2005 and you were forced to upgrade your project—primarily because of the conversion of the project file to an MSBuild format. The curious would poke around by opening their .CSPROJ files in Notepad and taking a look. The truly curious would take it a step further and start learning this new language, in order to make their desktop builds more interesting. My interest in MSBuild came from a Team Foundation Build perspective. Knowing that Team Foundation Build is a critical piece of the Visual Studio Team System puzzle, I spent a considerable amount of energy learning its inner workings. Fortunately, the majority of functionality in Team Build is provided by MSBuild so, as a side benefit, I was able to learn this new dark art. And it rocks!

What’s been missing until now is a solid reference and tutorial on MSBuild. Inside the Microsoft Build Engine fills that void. No longer will build engineers or build stuckees be forced to search for understanding and examples. From the very first chapter you will learn the key elements: tasks, targets, and properties. This provides a quick start into using MSBuild and sends you down the road of productivity.

Continuing on, you will drill down to learn all of the other capabilities, tricks, and time-saving features of MSBuild, enabling you to automate the really difficult builds. The final chapters reveal a nice surprise, which is a discussion of Team Foundation Build, and how MSBuild uniquely works within it.

I’m sure you will enjoy this read. Each chapter contains scripts, screenshots, and troubleshooting advice, and not just commentary. In fact, the commentary section is almost finished—just give me one more thought. I’d just like to make a prediction. I predict that this book will become stained by coffee, crumbs, and greasy fingers and otherwise mistreated due its close proximity to the keyboard and general overuse.

---Richard Hundhausen, VSTS MVP, RD, author of Working with Microsoft Visual Studio 2005 Team System (Microsoft Press, 2005), www.accentient.com

Here’s an excerpt from the book’s Introduction:

Introduction

As software complexity continues to increase, more emphasis is being placed on proper build practices. Previously (before .NET 2.0) the build process for .NET applications was mostly a black box. Now this process has been completely externalized in the Microsoft Build Engine, MSBuild. MSBuild allows you to take control over every aspect of the build process. Since the release of MSBuild, there has been a need for a definitive reference. Inside the Microsoft Build Engine is that definitive reference! We have been working for over a year on this book, and the MSBuild team has been involved right from the beginning.

MSBuild files are just XML files. Starting with Visual Studio 2005 managed projects use the MSBuild file format. Because of this you are able to fine-tune, or even completely change, how your projects are built. Using MSBuild you can customize your build process by adding steps such as code generation, unit testing, or code analysis. You can also use MSBuild to assist in automating the build and deployment process, as well as implementing continuous integration.

In this book we start with the fundamentals of MSBuild, like properties and items, and work up to advanced topics such as custom tasks and batching. Throughout these chapters you will be guided with expert insight and powerful examples. You will learn how MSBuild evaluates properties, items and conditions as well as how targets are executed. Chapters 8 and 9 are dedicated to applying the MSBuild concepts learned. Chapter 9 focuses on topics relating to Web development.

This book contains 12 chapters, nine of which are devoted to MSBuild. The remaining three chapters are focused on Team Foundation Build 2008 (Team Build). Team Build 2008 is the latest version of the build automation component of Visual Studio Team System. It takes MSBuild to the next level by allowing it to scale to the team, product, or enterprise level. This is achieved by tight integration with the other components of Visual Studio Team System, including version control, testing, work item tracking, and reporting.

Team Build was one of the most enhanced components in Visual Studio Team System 2008 and addressed a number of limitations in earlier versions resulting in an extremely powerful platform for automating build processes. This version includes functionality such as allowing builds to be queued on build machines, retention policies to automatically remove unneeded builds, and an improved and easier-to-use API for integrating Team Build into your own applications or external processes.

The latter part of this book explores the functionality that ships with Team Build 2008 and how it can be configured, customized, and extended to automate the end-to-end build process. This includes how to customize the build process to implement common requirements such as generating API documentation, zipping build outputs and source code, and versioning assemblies. Finally, we’ll look at some of the Team Build functionality in Visual Studio Team System 2010.

Who Is This Book For?

This book is written for everyone who uses MSBuild or Team Build. If you are using Visual Studio to write managed applications then you are already using MSBuild. Inside the Microsoft Build Engine is for all .NET developers and build masters. If you are interested in learning more about how your applications are being built and how you can customize this process then you need this book. If you are currently using or are interested in using Team Build then this book is for you.

This book will help the needs of enterprise teams as well as individuals. Readers should be familiar with creating .NET applications. The reader is not required to be familiar with the build process, as this book will start from the basics and build on that. Because one of the most effective methods for learning is through examples, this book contains many examples.

Organization of This Book

Inside the Microsoft Build Engine is divided into five parts:

Part I, “Overview,” describes all the fundamentals of creating and extending MSBuild project files. Chapter 1, “MSBuild Quick Start,” is a brief chapter to get you started quickly with MSBuild. If you are already familiar with MSBuild then you can skip this chapter; its content will be covered in more detail within chapters 2 and 3. Chapter 2, “MSBuild Deep Dive, Part 1,” discusses such things as static properties, static items, targets, tasks, and msbuild.exe usage. Chapter 3, “MSBuild Deep Dive, Part 2,” extends on Chapter 2 with dynamic properties, dynamic items, how properties and items are evaluated, importing external files, and extending the build process.

Part II, “Customizing MSBuild,” covers the two ways that MSBuild can be extended: custom tasks and custom loggers. Chapter 4, “Custom Tasks,” covers all that you need to know to create your own custom MSBuild tasks. Chapter 5, “Custom Loggers,” details how to create custom loggers and how to attach them to your build process.

Part III, “Advanced MSBuild Topics,” discusses advanced MSBuild concepts. Chapter 6, “Batching and Incremental Builds,” covers two very important topics, MSBuild batching and supporting incremental building. Batching is the process of categorizing items and processing them in batches. Incremental building enables MSBuild to detect when a target is up-to-date and can be skipped. Incremental building can drastically reduce build times for most developer builds. Chapter 7, “External Tools,” provides some guidelines for integrating external tools into the build process. It also shows how NUnit and FXCop can be integrated in the build process in a reusable fashion.

Part IV, “MSBuild Cookbook,” consists of two chapters that are devoted to real-world examples. Chapter 8, “Practical Applications, Part 1,” contains several examples, including: setting the assembly version, customizing the build process in build labs, handling errors, and replacing values in configuration files. Chapter 9, “Practical Applications, Part 2,” covers more examples, most of which are targeted toward developers who are building Web applications using .NET. It includes Web Deployment Projects, starting and stopping services, zipping output files, compressing Javascript file, and encrypting the web.config file.

Part V, “Team Foundation Build,” is devoted to Team Build. Chapter 10, “Team Build Quick Start,” covers the installation, configuration, and usage of Team Build. Chapter 11, “Team Build Deep Dive,” covers how to get the most out of Team Build by customizing and extending the default build process and how to integrate with Team Build using the Team Build API. It also covers things to be aware of when upgrading from Team Build 2005. Finally, Chapter 12, “Team Build Cookbook,” covers a number of common build requirements such as generating API documentation, zipping binaries and source, sharing customizations, and more.

The first Amazon review of the book was posted this week and is here.

You can see a video of Sayed discussing using MSBuild and Web Deployment Projects to automate deployment of Web Projects at http://channel9.msdn.com/posts/brianjo/Sayed-Hashimi-on-MS-Build/.

Finally, Sayed will be speaking at the South Florida .NET Code Camp (“a FREE one day GEEK FEST”) on Saturday, February 7 in Miramar, Florida. If you’re in the area and you’re interested in MSBuild, this is a great event to attend. (Fellow Microsoft Press author Shawn Wildermuth will also be there.)

You have been listening to “MSBuild” on channel SYED.

Share this post :
  • PingBack from http://blog.a-foton.ru/index.php/2009/01/31/all-sayed-all-the-time-and-msbuild/

  • The Microsoft Press Blog on All Sayed all the time (and MSBuild) Willy-Peter Schaub on SDLC - Software

  • Another great review of Sayed Ibrahim Hashimi’s "Inside the Microsoft Build Engine: Using MSBuild and Team Foundation Build" (Microsoft Press, 2009).

  • We won’t keep this up (although the streak might continue), but the third review on Amazon of Sayed Ibrahim

  • And the reason I can’t resist is that the fourth Amazon review of their Inside the Microsoft Build Engine:

  • Steven St Jean just posted a review of Inside the Microsoft Build Engine: Using MSBuild and Team Foundation

  • In late March , the last time we checked in on Amazon reviews of Inside the Microsoft Build Engine: Using

  • I really like the book you described. I had read it in 5 days.

  • Very well written book. It provides a comprehensive insight and is really to recommend.

  • That is a very good book.

  • I like the book which you mentioned, it is really a great source of information.

    Cheers,

    Manfred

Page 1 of 1 (11 items)
Leave a Comment
  • Please add 4 and 8 and type the answer here:
  • Post