MSBuild Concepts

12
A Primer to MSBuild MSBuild Fundamentals Praveen Chamarthi

Transcript of MSBuild Concepts

Page 1: MSBuild Concepts

A Primer to MSBuildMSBuild Fundamentals

Praveen Chamarthi

Page 2: MSBuild Concepts

MSBuild Fundamentals

• Properties• PropertyGroups

• Items• ItemGroups

• Tasks• Targets

Page 3: MSBuild Concepts

Property Property

Property Property

Item

Item Item

Item

PropertyGroup

ItemGroup

Target

TaskTask

TaskTask

Page 4: MSBuild Concepts

Properties

• Properties are the variables of a build script

• Properties are part of a PropertyGroup

• Properties can be referenced using $(<propertyname>) syntax

• Environment variables are available as properties e.g. $(PATH)

Page 5: MSBuild Concepts

Items

• Items are used to define inputs e.g. a source file

• Items are part of a ItemGroup

• Items can be referenced using @(<itemname>) syntax

Page 6: MSBuild Concepts

Tasks

• Tasks are the core to a build process – contains steps to be performed

• Tasks are part of a Target

• Tasks can use items and/or properties as inputs

Page 7: MSBuild Concepts

Targets

• Targets are a collection of Tasks

• Tasks defined in the Target are executed in the defined order

Page 8: MSBuild Concepts

Standard MSBuild Tasks

• Command Line Tool Wrappers• AL, Sgen, Csc, MSBuild, VCBuild, SignFile (Digitally Sign Files)

• File and Directory Manipulation• Copy, Delete, MakeDir, RemoveDir, ReadLinesFromFile, WriteLinesToFile

• Assembly and COM Manipulation• GetAssemblyIdentity, ResolveAssemblyReference, UnregisterAssembly

Page 9: MSBuild Concepts

Extending MSBuild Standard Tasks

• MSBuild Community Tasks is an open source project for MSBuildTasks

• https://github.com/loresoft/msbuildtasks

• Some Tasks include:• FTP, Email, Math, Registry, Regex, Services, SQL Commands, Subversion, ZIP, SourceSafe,

XML

• You can create your own tasks using C#• Extend Microsoft.Build.Framework• Extend Microsoft.Build.Utilities

Page 10: MSBuild Concepts

Debugging Builds

• Use MSBuild command line switches to control the detail in the output

• /verbosity switch sets the level of verbosity a build can generate• Quiet

• Minimal

• Normal

• Detailed

• Diagnostic

Page 11: MSBuild Concepts

Parallel Building with MSBuild

• Using Parallel task in MSBuild Extension Pack

• Using Tasks BuildTargetsInParallel and BuildTargetSetsInParallel

Page 12: MSBuild Concepts

Questions