W

X

Tuesday, December 08, 2009

Visual Studio 2008 - Changing the application manifest template

After discovering that Windows 7 wants a special guid in the application manifest, I wanted to change VS 2008's default manifest so that it included this GUID by default.

Here is the procedure.

Navigate to
C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\VisualBasic\1033

Copy AppManifestInternal.zip to another directory. 
Extract the two files in AppManifestInternal.zip to a working directory. 
Change app.manifest as desired.

The following is the manifest that I am using.  It does not format properly here in the blog.


<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC Manifest Options
If you want to change the Windows User Account Control level replace the 
requestedExecutionLevel node with one of the following.
<requestedExecutionLevel  level="asInvoker" uiAccess="false" />
<requestedExecutionLevel  level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel  level="highestAvailable" uiAccess="false" />
If you want to utilize File and Registry Virtualization for backward 
compatibility then delete the requestedExecutionLevel node.
-->
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!--Windows 7-->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!--Windows Vista-->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
</application>
</compatibility>
</asmv1:assembly>

After you complete the changes, zip up the changed file (app.manifest) back into AppManifestInternal.zip.  Copy AppManifestInternal.zip back to the original directory.

Now navigate to
C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplatesCache\VisualBasic\1033\AppManifestInternal.zip

In this folder you will find the two files again.  This is in the cache directory.  Copy the app.manifest that you changed to this directory.

This completes the changes.  Now when you add an application manifest to a program using the View UAC Settings button, it will contain the changes for Windows 7.

No comments: