Embedding a Manifest File Using Visual Studio


Since writing my last post, I thought it would be good to have some more information about how to actually embed a manifest as part of the build process in Visual Studio.


Unmanaged Projects 


Embedding a manifest file for an unmanaged project: simply add the manifest in the project and Visual Studio will recognize it automatically.


Managed Projects 


For a managed project it is not so simple:


The following extra steps are required for embedding it:
1) Add a new Item as an XMLFile called for instance "mymanifest.manifest"
2) Check the Build action property of the file, it should be “None” because VS doesn’t accept automatically the manifest file for managed code.
3) Add a resource file in order to embed the manifest file ManagedManifest.rc, check the build action property it should be “Content”
4) Open the RC file within VS editor and add the following :
#define RT_MANIFEST 24 // provided by WIN32 SDK
#define APP_MANIFEST 1 // provided by WIN32 SDK
APP_MANIFEST RT_MANIFEST mymanifest.manifest.
5) Add a custom Pre-Build event:
"C:\Program Files\Microsoft SDKs\Windows\v6.0\Bin\rc.exe" "$(ProjectDir)ManagedManifest.rc"
6) Unload the project by right clicking on the project name in the Solution Explorer->Unload
7) Edit the project file (.csj)Right click on the project name in the Solution Explorer->Modify <project name>.csj
8) Add a new property group :
<PropertyGroup>
    <Win32Resource>ManagedManifest.res</Win32Resource>
  </PropertyGroup>
9) Close the file and reload it , right click on the project name in the Solution Explorer-> Reload
10) Build the solution


Chris Forster

Skip to main content