Welcome to MSDN Blogs Sign in | Join | Help

How To: Insert Custom Process at Specific Points During Build

Today Kieran, Faisal, and I met with one of our partners to give them an introduction to MSBuild. During the discussion one of them asked us about the different places someone can plug into the standard Visual Studio build process (as defined by the Microsoft.Common.Targets file).

In general the way you hook into the existing build process is by re-defining targets that exist in Microsoft.Common.Targets in either your project file or in your own .targets file. Faisal wrote about the specifics of what the XML looks like in an earlier post, but it doesn't look like we have a list of those targets documented anywhere (other than in Microsoft.Common.Targets!), so here's an easier to parse list:

Target Name Description
BeforeBuild
AfterBuild
These are primary for legacy support with prior versions of Visual Studio 2005. Tasks inserted in these targets will run before and after everything else in the build.
BeforeRebuild
AfterRebuild
Tasks inserted in these targets run before and after the core rebuild functionality is invoked. The flow is: BeforeRebuild, Clean, the default target (Build), and After Rebuild.
BeforeClean
AfterClean
Tasks inserted in these targets run before and after the core clean functionality is invoked.
BeforePublish
AfterPublish
Tasks inserted in these targets run before and after the core publish functionality is invoked.
BeforeResolveReferences
AfterResolveReferences
Tasks inserted in these targets run before and after assembly references are resolved.
BeforeCompile
AfterCompile
Tasks inserted in these targets run before and after core compliation is done. Typically most custom work is done in one of these two targets.
BeforeResGen
AfterResGen
Tasks inserted in these targets run before and after resources are generated.

[ Author: Neil Enns ]

Published Wednesday, November 23, 2005 7:08 PM by msbuild
Filed under: ,

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

Wednesday, November 30, 2005 1:20 AM by Sayed Ibrahim Hashimi

# re: How To: Insert Custom Process at Specific Points During Build

"it doesn't look like we have a list of those targets documented anywhere (other than in Microsoft.Common.Targets!)"

There is this post on the MSBuild forum at:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=58137&SiteID=1
By Dan Moseley
Thursday, December 01, 2005 1:11 AM by msbuild

# re: How To: Insert Custom Process at Specific Points During Build

Yes, Dan's on our team and he wrote a great post in the forum. It doesn't, however, include the specific list of targets you can override in the build process.

Neil
Thursday, May 04, 2006 7:47 PM by Judah

# re: How To: Insert Custom Process at Specific Points During Build

Hi guys

I'm trying to obfuscate an assembly. It works fine until I go to publish, that's when the compiler publishes an assembly without the obfuscation.

How can I obfuscate my assembly so that it gets published as obfuscated? At what build target should i obfuscate? I tried the BeforePublish target but nothing seems to happen. Any ideas?
Tuesday, May 09, 2006 10:23 AM by tek5lr7@altavista.com

# re: How To: Insert Custom Process at Specific Points During Build

online directory main
Friday, September 29, 2006 3:46 PM by Derek Smyth's Software Development Blog

# Compiling class libraries using Visual Studio Standard

About a week ago a VB developer, who I was giving an overview to an .NET application, asked about creating
Thursday, October 01, 2009 4:17 PM by Sayed Ibrahim Hashimi

# re: How To: Insert Custom Process at Specific Points During Build

From the description of BeforeBuild and AfterBuild "These are primary for legacy support ..." Is this being confused with the PreBuildEvent and PostBuildEvent target/properties? While I don't like BeforeBuild and AfterBuild targets myself too much, I still suggest people to use it for non-reusable project files.

Leave a Comment

(required) 
required 
(required) 

  
Enter Code Here: Required
 
Page view tracker