Click here to Skip to main content
15,867,568 members
Articles / Programming Languages / Visual Basic
Article

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 61.2K   356   21   9
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


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!

http://www.pagelabs.com

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 
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
cSaRebel10-Jan-06 8:05
cSaRebel10-Jan-06 8:05 
AnswerRe: WDM DLL question Pin
TylerBrinks10-Jun-06 16:45
TylerBrinks10-Jun-06 16:45 
Any library containing congrols that would otherwise work with a standard manifest file will work with this method.
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.