Click here to Skip to main content
15,617,328 members
Articles / Programming Languages / Visual Basic
Posted 22 Feb 2005


21 bookmarked

Automate the Manifest Injection Process

Rate me:
Please Sign up or sign in to vote.
4.14/5 (5 votes)
22 Feb 20052 min read
Automate manifest injection using post-build events.

Sample Image - ManifestInjection2.jpg


In a previous article, I explored the ability to add a manifest as a resource to a compiled executable. This process allowed for XP themes to display correctly without the burden of yet another file to manage when distributing an application. The down side to my first article is that the process of injecting the manifest is cumbersome and is required each time the source code is compiled.

This article aims at streamlining the process of injecting the manifest in a “hands-off” manner by automatically injecting the manifest on the completion of each new build. The solution uses the Post-build property of a project to call a console version of the manifest injector, so no extra work is required when building the project.

Project Setup

To set up a project, first download the source for this article. Make note of the path to the ManifestConsole.exe. Now open a Windows Forms project and open up the project properties dialog. Select the Build Events option on the left. Click in the box for the Post-build Event Command Line. Click on the ellipsis button to open up the Post-build editor.

Post-build Command Line

The editor is where we’ll specify the path and arguments to call the ManifestConsole.exe. The ManifestConsole.exe requires two command line arguments. The first argument is the path to the target executable (i.e., which EXE to inject the manifest into). The second argument is the path to the manifest (for this example, it’s your project’s root directory).

An example of the command is as follows:

C:\ManifestInjection\ManifestConsole\bin\Release\ManifestConsole.exe $(TargetPath) $(ProjectDir)WindowsApplication1.exe.manifest

Post-build Editor

Ready to Build

If we dissect this command line, we’ll see three things. First is the path to the ManifestConsole.exe file. For now, this is the same location you put the source for this article. Change the C:\<path> accordingly. The first command line argument, $(TargetPath), will be filled in by Visual Studio with the EXE you are building. The last argument, $(ProjectDir)WindowsApplication1.exe.manifest, points to your project directory to a file named WindowsApplication1.exe.manifest. Change this argument to point to your manifest and you’re ready to build your project. *Note:* click the Macros button on the editor window for a list of paths Visual Studio .NET supports. Check the Output window for status on the injection process when you build your project. Now… run your app! Don’t you just love automation?


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Written By
Web Developer PageLabs
United States United States
I'm the founder of PageLabs, a web-based performance and SEO optimization site.

Give your site a boost in performance, even take a free speed test!

Comments and Discussions

GeneralTab controls not changing Pin
Russell Gantman10-Oct-07 4:24
Russell Gantman10-Oct-07 4:24 
GeneralRe: Tab controls not changing Pin
TylerBrinks10-Oct-07 4:55
TylerBrinks10-Oct-07 4:55 
GeneralRe: Tab controls not changing Pin
Russell Gantman10-Oct-07 5:03
Russell Gantman10-Oct-07 5:03 
I did that and there were no (property) differences, so therefore the differences had to be in code.
When I compared my code to the "standard" I realized what was going on...

I added a delegate to make my TabControl to perform an OwnerDraw (to allow me to make the header text bold).
this.tabControl1.DrawMode = System.Windows.Forms.TabDrawMode.OwnerDrawFixed;
this.tabControl1.DrawItem += new DrawItemEventHandler(this.tabControl1_DrawItem);

When I removed the above lines, all worked.

Thanks for your help...It pointed me in the correct direction.
Now all I need to do is figure out how to make the tab name bold for the selected tab.

I skate to where the puck is going to be, not where it is.
Wayne Gretzky

Questioncan't get it to work Pin
Six CodeMaster5-Jun-06 9:11
Six CodeMaster5-Jun-06 9:11 
AnswerRe: can't get it to work Pin
Six CodeMaster7-Jun-06 8:17
Six CodeMaster7-Jun-06 8:17 
QuestionWDM DLL question Pin
tfryar10-Jan-06 8:05
tfryar10-Jan-06 8:05 
AnswerRe: WDM DLL question Pin
TylerBrinks10-Jun-06 16:45
TylerBrinks10-Jun-06 16:45 
Generalbeware of spaces Pin
dosdemon12-Sep-05 0:28
dosdemon12-Sep-05 0:28 
GeneralRe: beware of spaces Pin
Mikael Levn18-Nov-05 8:14
Mikael Levn18-Nov-05 8:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.