Become a Task Master - Customizing the build process using Visual Studio

Published 03 October 07 07:58 AM | kevin 

 To understand the build process, we must cover a few general points:

  • The default Visual Studio build engine is not MSBuild. For the purposes of this blog, when writing custom tasks we employee either MSBuild or Team Build (build engine that Visual Studio Team Foundation Server  uses).
  • The build uses project files for build instructions (.csproj/.vbproj/.proj). The project file contains XML like build instructions which can be customized. MSBuild or Team Build "reads" the project file for those build instructions.
  • The build file contains pre-defined targets to call tasks (both pre-defined and custom). You can roughly translate targets to build events. For example there is a BeforeBuild target as well as an AfterBuild target. Any guess as to when those targets "fire" during the build? Those pre-defined targets are known by MSBuild (or Team Build) as they are part of the Microsoft Build Framework. We can also create customized targets (covered later).
  • We tie tasks to targets. A target can contain 1 or more tasks to execute when it is called. So you can also think of a target as a container for tasks. When BeforeBuild gets called, execute tasks x, y, and z.

With the preliminaries covered, will cover these items:

  1. Part 1 - Adding MSBuild to your Visual Studio IDE....
  2. Part 2 - Coding a custom task...
  3. Part 3 - Adding the custom task to a build...

Additional material maybe available on http://kevinisrael.com

*******This blog will cover part 1. I will blog Part 2 and 3 in the next couple of days...*******

 1) Adding MSBuild to your Visual Studio IDE

IDE Tools Menu

 

Click External Tools. From the next window click Add, then type MSBuild (or whatever..its just a name that makes sense right?). Much of this is setting up environment variables to use in the build...

External Tools

For the Command, Select the browse button. Browse to the MSBuild.exe file. This is typically found in C:\Windows\Microsoft\Framework\version number\

MSBuild path

After adding the Command, we need to add Arguments. Arguments consist of Project path \ FilePath and a switch...

Project Directory

Project File Name

 

Projct File Name

 At this point we add a switch /v:d (verbosity is detailed). We now add the initial directory.

 Make sure that you have Use Output window selected.

Click Apply. Now when you want to launch MSBuild simply go to Tools and Click MSBuild...

Launching MSBuild

Coming up on the next blog, Parts 2 and 3.

  1. Part 2 - Coding a custom task..
  2. Part 3 - Adding the custom task to a build...

Comments

No Comments
Anonymous comments are disabled