Building an Avalon application: Part 1
MSBuild is the new build platform for Microsoft and Visual Studio. It is completely transparent with regards to how it processes and builds software, enabling developers to orchestrate and build products in build lab environments where Visual Studio is not installed. The MSBuild engine synchronously executes a project file i.e. an XML file composed of a series of targets with pre-defined execution order, each target consisting of zero or more tasks.
Those familiar with Ant and its .NET clone NAnt, probably see the similarities. For others, the following couple paragraphs should serve to illustrate how targets and tasks help build applications.
For example, here's a simple project file with one target
HelloWorld.csusing the task
CSCinto the assembly
<Compile Include="HelloWorld.cs" />
If the project file were named
MyFirstApp.csprojyou may run this by specifying this on the command line:
MSBuild ships with the .NET runtime. This means if you have the .NET Framework, you can compile a typical application. Let us look at the important constituents of MSBuild as relevant to building Avalon applications:
|MSBuild.exe||The console application that consumes project files. Any C# or VB project you create in VS can be passed to MSBuild.exe to be built from the command-line.|
|Microsoft.Build.Engine.dll||Is the common build engine responsible for reading in and executing build scripts.|
|Microsoft.Build.Tasks.dll||contains MSBuild tasks which are discrete, reusable build components. For example, there’s a CSC task for invoking the C# compiler.|
|PresentationBuildTasks.dll||Contains Avalon's MSBuild tasks. These include MarkupCompilerPass1, MarkupCompilerPass1, FileClassifier, ResourcesGenerator etc.|
|Microsoft.Build.Utilities.dll||Offers a set of utilities classes that you would use if you were to write your own custom tasks.|
|Microsoft.Build.Framework.dll||Contains a set of interfaces that define the way the engine talks with tasks and loggers.|
|Microsoft.Build.Conversion.dll||Contains classes that help convert legacy VS .NET 2003 project formats to VS 2005 (Whidbey) MSBuild formats.|
Microsoft ships a bunch of
.targetsfiles that you may enlist in building your project. For example:
- Microsoft.Common.targets: A repository of common targets, the bulk of the build work is done in this file.
- Microsoft.CSharp.targets: This contains C# build logic
- Microsoft.VisualBasic.targets: This contains VB build logic
- Microsoft.WinFX.targets: Here's where all of the Avalon Build logic resides. This targets file does not ship with the .NET Framework runtime, instead gets installed on WinFX setup.
MarkupCompilerPass1 -> FileClassifier -> ResourcesGenerator (for Main assembly) -> CSC -> MarkupCompilerPass2 -> ResourcesGenerator (for Satellite assembly) -> AL -> CopyToOutput.
If you don't have a clue what this is, don't sweat. We will look at the Avalon Build process in more detail in future posts.