Click here to Skip to main content
Click here to Skip to main content
Go to top

Automate the Manifest Injection Process

, 22 Feb 2005
Rate this:
Please Sign up or sign in to vote.
Automate manifest injection using post-build events.

Sample Image - ManifestInjection2.jpg

Introduction

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?

License

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

Share

About the Author

TylerBrinks
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!
 
http://www.pagelabs.com
Follow on   Twitter

Comments and Discussions

 
GeneralTab controls not changing PinmemberRussell Gantman10-Oct-07 4:24 
GeneralRe: Tab controls not changing PinmemberAcoustic10-Oct-07 4:55 
GeneralRe: Tab controls not changing PinmemberRussell Gantman10-Oct-07 5:03 
Questioncan't get it to work PinmemberSix CodeMaster5-Jun-06 9:11 
AnswerRe: can't get it to work PinmemberSix CodeMaster7-Jun-06 8:17 
QuestionWDM DLL question Pinmembertfryar10-Jan-06 8:05 
AnswerRe: WDM DLL question PinmemberAcoustic10-Jun-06 16:45 
Generalbeware of spaces Pinmemberdosdemon12-Sep-05 0:28 
GeneralRe: beware of spaces PinmemberMikael Levén18-Nov-05 8:14 

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

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

| Advertise | Privacy | Mobile
Web03 | 2.8.140916.1 | Last Updated 22 Feb 2005
Article Copyright 2005 by TylerBrinks
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid