MSBuild Terminology


Let s establish definitions for some MSBuild elements. A Property is a key- value pair. A Property s value can originate from an environment variable, from a command-line switch, or from a Property definition in a project file, as shown here:

 <Property OutputDir="bin\" /> 

You can think of an Item as an array of files. An Item can contain wildcards and can exclude specific files. MSBuild uses the Type attribute of an Item to categorize items, as shown here:

 <Item Type="Compile Include="*.cs Exclude="DebugStuff.cs /> 

A Task is an atomic unit in the build process. A Task can accept input parameters from Property elements, Item elements, or plain strings. The Name of a Task identifies the build .NET data type required to perform the Task . A Task can emit Item s that other Task s consume . MSBuild includes many tasks , all of which can be broadly categorized as

  • .NET tool tasks

  • Deployment tasks

  • Shell tasks

For example, the Task with a Name of Csc invokes the C# compiler as the build tool, which compiles all Item elements specified in the Sources attribute (which specifies Item elements with a Type of Compile ) into an assembly, and produces the assembly as an output Item .

 <Task Name="Csc" AssemblyName="$(OutputDir)\HelloWorld.exe" 
Sources="@(Compile)" />

A Target is a single logical step in the build process. A Target can perform timestamp analysis. This means that a Target will not run if it s not required. A Target executes one or more Task s to perform the desired operations, as shown here:

 <Target Name="CopyToServer" 
Inputs="$(OutputDir)\HelloWorld.exe"
Outputs="\DeployServer$(BuildNum)\HelloWorld.exe"
DependsOnTargets="Compile">

<Task Name="Copy" ... />
</Target>

A Condition attribute is roughly equivalent to a simple if statement. A Condition can compare two strings or check for the existence of a file or directory. You can apply a Condition to any element in a project file. For example, here s a group of properties that are defined only when the Configuration property has the value Debug :

 <PropertyGroup Condition=" $(Configuration)== 


Introducing Microsoft WinFX
Introducing WinFX(TM) The Application Programming Interface for the Next Generation of Microsoft Windows Code Name Longhorn (Pro Developer)
ISBN: 0735620857
EAN: 2147483647
Year: 2004
Pages: 83
Authors: Brent Rector

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net