How to embed / merge multiple manifest files in a C # application?

In Visual Studio, you can set the "Additional manifest files" option in C ++ projects to combine an additional manifest file into the default application manifest of the application.

We use this parameter with the general "compatibility manifest", which includes only a list of supported OS versions:

<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> <application> <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/> <!--app support for Windows Vista --> <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/> <!--app support for Windows 7 --> <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/> <!--app support for Windows 8 --> <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/> <!--app support for Windows 8.1 --> </application> </compatibility> </assembly> 

Now we would like to embed this common manifest in existing WinForms / WPF applications so that it merges with existing application manifest files. Is this possible with C # projects? We would like to avoid defining this OS list in every project.

+11
c # visual-studio manifest
source share
1 answer

To add or update a manifest, you can use the post-build action that calls ManifestTool mt.exe (from the Windows SDK):

mt.exe -updateresource:"myapp.exe";#1 -manifest "additional.manifest"

See the MT command line for more information.

Note that when you decide to sign the assembly, you must re-sign it after this modification:

sn.exe -R "myapp.exe" "mykey.snk"

-one
source share

All Articles