Presentation is loading. Please wait.

Presentation is loading. Please wait.

MSBuild: Architecting a Customized Build System Rajeev Goel, TLN402 Software Development Engineer MSBuild Microsoft Corporation.

Similar presentations


Presentation on theme: "MSBuild: Architecting a Customized Build System Rajeev Goel, TLN402 Software Development Engineer MSBuild Microsoft Corporation."— Presentation transcript:

1 MSBuild: Architecting a Customized Build System Rajeev Goel, rgoel@microsoft.com TLN402 Software Development Engineer MSBuild Microsoft Corporation

2 2 Dogfooding Developer Tools Within Microsoft June 2002 (3+ years ago)   Debugger Editor/Find In Files Help/Samples Project system/Intellisense/ Designers Build system (Visual Studio.NET 2003)

3 3 Dogfooding Developer Tools Within Microsoft September 2005 (now) 30% of DevDiv code (.NET Framework + Visual Studio) now builds every day in the build lab using MSBuild and TeamBuild! 100% conversion to MSBuild by March 2006 Single project file for command-line and Visual Studio IDE builds Full IDE development experience, including intellisense, refactoring, designers, etc. My mission: Help you do this too!

4 4 In This Session… Part 1. MSBuild Basics Part 2. The Power of Item Metadata Part 3. The Power of the MSBuild Task Part 4. Team Build

5 5 Part 1: MSBuild Basics

6 6 The Building Blocks Overall architecture of MSBuild and Team Build.NET Framework 2.0 MSBuild.exe Visual Studio 2005 project system MSBuild (core components) Engine Tasks Loggers.TARGETS Team Foundation Server Source control Work item tracking Team Build Web Service TasksLoggers.TARGETS.NET Framework 2.0 Redist

7 7 What Is MSBuild? A fully extensible build system that ships with the.NET Framework 2.0. A build system that is seamlessly integrated with Visual Studio 2005. An XML file format for describing your project’s properties, items, and build process. A soon-to-be shipping product! November 7, 2005!!

8 8 MSBuild Basics

9 9 public class MakeDir : Task { private string[] directories; private string[] directories; public string Directories public string Directories { get {return directories;} get {return directories;} set {directories = value;} set {directories = value;} } public override bool Execute() public override bool Execute() { foreach (string directory in directories) foreach (string directory in directories) { System.IO.Directory.CreateDirectory(directory); System.IO.Directory.CreateDirectory(directory); } return true; return true; }} MSBuild File Format Basics (cont.) Task Implementation

10 10 Part 2: The Power of Item Metadata

11 11 Item Metadata Use item metadata to store additional information associated with each item Item metadata always follows the item around <ItemGroup> en-US en-US Don B Don B it-CH it-CH Anders H Anders H </ItemGroup>

12 12 Built-in Item Metadata FullPathRootDirFilenameExtensionRelativeDirDirectory RecursiveDirModifiedTimeCreationTimeAccessedTimeIdentity <EmbeddedResource Include=“ c:\ PDC2005\MSBuildDemo\ Splash.bmp”/> c:\ PDC2005\MSBuildDemo\ Splash.bmp”/> RootDir RelativeDir Filename Extension

13 13 Batching Example: Bucketing items Build satellite assemblies by invoking “AL” once per Culture en-US it-CH pa-IN en-US en-US pa-IN %(Culture) 001.bmp 002.bmp 003.wmv 004.bmp 005.wmv 006.xml @(EmbeddedResource) “ <AL EmbedResources=“@(EmbeddedResource)” “ OutputAssembly=“%(Culture)\Resources.dll” />

14 14 Batching On Single Metadata

15 15 Batching (cont.) Example: Bucketing items Build satellite assemblies, one per Culture/Extension en-US.bmp it-CH.bmp pa-IN.wmv en-US.bmp en-US.wmv pa-IN.xml %(Culture) 001.bmp 002.bmp 003.wmv 004.bmp 005.wmv 006.xml @(EmbeddedResource) “ <AL EmbedResources=“@(EmbeddedResource)” “ OutputAssembly=“%(Culture)\My%(Extension)\Resources.dll” /> %(Extension)

16 16 Batching (cont.) Example: Looping Invoke a task once per item in your item list

17 17 Batching (cont.) Example: Filtering Copy only the files in the @(SourceFile) list that have a.TXT file extension <Copy SourceFiles=“@(SourceFile)” SourceFiles=“@(SourceFile)” DestinationFolder=“bin\debug\” DestinationFolder=“bin\debug\” Condition=“ %(Extension) == ‘.TXT’ ” Condition=“ %(Extension) == ‘.TXT’ ”/>

18 18 Part 3: The Power Of The MSBuild Task

19 19 The Task Executes target(s) in another MSBuild project Runs entirely in-process Never builds the same target in the same project twice within a build Used for communication between projects Gathering information from referenced projects Building child projects

20 20 Project-to-Project References Automatically picks up the right configuration Automatically rebuilds the referenced project if necessary Automatically cleans the referenced project when parent is cleaned Referenced project need not be in the same.SLN </MSBuild>

21 21 The MSBuild Task

22 22 Passing In Properties To The Child Project The “Properties” parameter can be used to pass in global overriding properties into the child project Different sets of global properties cause new instances of the child project to get loaded <MSBuild Projects=“MyApp1.vbproj” <MSBuild Projects=“MyApp1.vbproj” Targets=“Build” Targets=“Build” Properties=“Configuration=Debug” /> Properties=“Configuration=Debug” /> <MSBuild Projects=“MyApp1.vbproj” <MSBuild Projects=“MyApp1.vbproj” Targets=“Build” Targets=“Build” Properties=“Configuration=Release” /> Properties=“Configuration=Release” /></Target>

23 23 Part 4: Team Build

24 24 What Is Team Build? A fully automated build solution that is easy to use and configure Capable of a complete end-to-end build Seamlessly integrated into Visual Studio Team System and Team Foundation Server Fully extensible through standard MSBuild extensibility mechanisms In other words, it’s a build lab in a box

25 25 Team Build

26 26 Team Build Architecture Team Foundation Client Application Tier Build Machine Create build type Create build type Start build Start build View Reports View Reports Team Build Web Services Services MSBuild Drop Location Data Tier Sources Sources Work items Work items Team Build data Team Build data Team Foundation warehouse

27 27 Team Build Build Execution Get sources from source control Produce build report and send mail Publish build outputs Update work items Build projects (including code analysis) Run tests and gather code coverage

28 28 Building In The Future Faster builds through Multi-proc builds Distributed build Extensible mechanisms for achieving incremental builds Easier task authoring Example: Inline your task code Example: Auto ToolTask generator Example: Inlining task code. (Hypothetical only; will not compile.) public class CharacterReplace : Task public class CharacterReplace : Task { … public override bool Execute() public override bool Execute() { Result = Input.Replace(OldString, NewString); Result = Input.Replace(OldString, NewString); return true; return true; } } <CharacterReplace Input=“$(UnescapedOutputPath)” <CharacterReplace Input=“$(UnescapedOutputPath)” OldString=“\” NewString=“\\”> OldString=“\” NewString=“\\”> </Project> Example: Auto ToolTask Generator. (Hypothetical only.) <GacUtil InstallAssemblies=“@(FinalOutputAssembly)” <GacUtil InstallAssemblies=“@(FinalOutputAssembly)” ForceInstall=“true” /> ForceInstall=“true” /> </Project>

29 29 Building In The Future (cont.) Continuous Integration through Team Build Richer IDE integration; IDE becomes a visual build designer File format enhancements, including XML namespaces.SLN file format becomes MSBuild Debugging the build process

30 30 MSBuild Pseudo-Debugger

31 31 Call To Action Start converting your existing builds to MSBuild now! Watch for MSBuild cameos throughout PDC! Send product feedback, questions, and success stories to msbuild@microsoft.com We want your feedback! Rate this session online at http://commnet.microsoftpdc.com

32 32 Community Resources For MSBuild Tools & Languages Track Lounge (Big Room) Either Faisal or Rajeev will be there all day Thursday. Other great sessions (presented earlier) TLNL01 “MSBuild Tips and Tricks” TLN301 “Behind the Scenes of Team Foundation Server” Join the MSBuild table at “Ask The Experts”. Thursday, 6:30pm, Big Room

33 33 Community Resources For MSBuild (cont.) Demo bits Available through CommNet post-conference See me in the Tools & Languages Track Lounge Send mail to msbuild@microsoft.com Channel 9 wiki – http://channel9.msdn.com/wiki/default.aspx/MSBuild.HomePage MSBuild MSDN Forums – http://forums.microsoft.com/msdn/ShowForum.aspx?ForumID=27 Latest MSBuild docs – http://msdn2.microsoft.com

34 34 … Have A Great Time At The Party!!! And Finally …

35 © 2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.


Download ppt "MSBuild: Architecting a Customized Build System Rajeev Goel, TLN402 Software Development Engineer MSBuild Microsoft Corporation."

Similar presentations


Ads by Google