Presentation is loading. Please wait.

Presentation is loading. Please wait.

MSBuild Unveiled Peter Schneider MVP Visual Developer – Visual C# MCT, MCSD.NET, MCAD.NET, MCDBA

Similar presentations


Presentation on theme: "MSBuild Unveiled Peter Schneider MVP Visual Developer – Visual C# MCT, MCSD.NET, MCAD.NET, MCDBA"— Presentation transcript:

1 MSBuild Unveiled Peter Schneider MVP Visual Developer – Visual C# MCT, MCSD.NET, MCAD.NET, MCDBA ps@ugwa.net

2 In This Session… MSBuild Architecture MSBuild Architecture MSBuild – File Format MSBuild – File Format MSBuild – Tips & Tricks MSBuild – Tips & Tricks

3 Authors PROJECT FILE - $%#^$&% - @$#%$^# Abracadabra Feeds Visual Studio.NET 2002/2003 VS Build System Produces Final Product Pre build step 0011010101111001011011011001110010100111 Post build step

4 Final Product Produces Feeds Authors DEVELOPER Authors MSBuild Design Goals MSBuild MSBuild PROJECT FILE

5 MSBuild in 5 minutes The underlying build engine in Visual Studio 2005 The underlying build engine in Visual Studio 2005 Fully open and published XML file format for describing build Fully open and published XML file format for describing build Visual Studio 2005 build is fully customizable Visual Studio 2005 build is fully customizable You extend the build by writing managed code (tasks and loggers) You extend the build by writing managed code (tasks and loggers) You don’t need the IDE to build Visual Studio projects You don’t need the IDE to build Visual Studio projects

6 MSBuild File Format MyCoolApp true $(AppName).exe <Csc Sources=“@(Compile)” EmitDebugInformation=“$(DebugSymbols)” OutputAssembly=“$(OutputAssembly)”/>

7 MSBuild Key Components Items Items Properties Properties Targets Targets Tasks Tasks

8 Build Items Represent Input to the build system Represent Input to the build system Grouped into Item Collections Grouped into Item Collections  Use userdefined CollectionNames Are used as Parameters for Tasks Are used as Parameters for Tasks Use Include and Exclude Attributes, Wildcards (**,*,?) Use Include and Exclude Attributes, Wildcards (**,*,?)

9 Build Items Reference ItemGroups with @(ItemCollectionName) Example: Reference ItemGroups with @(ItemCollectionName) Example:

10 Build Item Metadata Items may contain MetaData Items may contain MetaData 1 2 Used for batching Used for batching

11 Well Known Item Meta Data %(FullPath)%(RootDir)%(Filename)%(Extension)%(RelativeDir)%(Directory) %(RecursiveDir) %(Identity) %(ModifiedTime) %(CreationTime) %(AccessedTime) <Copy SourceFiles=“@(Compile)” DestinationFiles=“%(Compile.Filename).bak” />

12 Build Properties Properties are key/value pairs used to configure builds Properties are key/value pairs used to configure builds Defined in PropertyGroups Defined in PropertyGroups Debug Reference Properties with $(Propertyname) e.g. $(Configuration) Reference Properties with $(Propertyname) e.g. $(Configuration)

13 Reserved Properties  MSBuildProjectDirectory  MSBuildProjectFile  MSBuildProjectExtension  MSBuildProjectFullPath  MSBuildProjectName  MSBuildBinPath  MSBuildProjectDefaultTargets  MSBuildExtensionsPath Some PropertyNames are reserved: Some PropertyNames are reserved: Environment Variables are accessible as Properties Environment Variables are accessible as Properties

14 Setting Properties You can set Properties from the commandline You can set Properties from the commandline MSBuild.exe MyProject.proj /p:Configuration=Debug MSBuild.exe MyProject.proj /p:Configuration=Debug;Another=Test You can set Properties depending on other properties You can set Properties depending on other properties full

15 Build Targets Targets group tasks together in a particular order Targets group tasks together in a particular order Allows sections of the build process to be called individually (Commandline, CallTarget Task) Allows sections of the build process to be called individually (Commandline, CallTarget Task) MSBuild.exe MyProject.proj /t:Compile MSBuild.exe MyProject.proj /t:Clean;Compile

16 Default Targets Use DefaultTargets Attribute Use DefaultTargets Attribute... InitialTargets are executed first InitialTargets are executed first...

17 Incremental Builds Reduce build time Reduce build time Only builds targets which are out-of- date or not yet built Only builds targets which are out-of- date or not yet built Specify Inputs and Outputs of the target Specify Inputs and Outputs of the target <Target Name=“Compile” Inputs = “@(SourceFiles)” Outputs = “HelloWorld.exe” >

18 Build Tasks A Task is a unit of executable code which performs atomic build operations A Task is a unit of executable code which performs atomic build operations

19 Build Task Outputs Task can return Output mapped to Items or Properties Task can return Output mapped to Items or Properties

20 Build Task ContinueOnError Specify the ContinueOnError Attribute to succeed target for non-critical tasks Specify the ContinueOnError Attribute to succeed target for non-critical tasks Other possibilities: Other possibilities:

21 Project Elements Use Choose, When, Otherwise Elements Use Choose, When, Otherwise Elements Test

22 Summary Properties Properties Items Items Targets Targets Tasks Tasks Projects Projects


Download ppt "MSBuild Unveiled Peter Schneider MVP Visual Developer – Visual C# MCT, MCSD.NET, MCAD.NET, MCDBA"

Similar presentations


Ads by Google