Manifest not installed with setup
- So I created a manifest:
And added the necessary post-build event:<?xml version="1.0" encoding="UTF-8"?> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> <security> <requestedPrivileges> <requestedExecutionLevel level="asInvoker"/> </requestedPrivileges> </security> </trustInfo> </assembly>
"C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\mt.exe" -manifest "$(ProjectDir)$(TargetName).exe.manifest" –outputresource:"$(TargetDir)$(TargetFileName)";#1
But when I install with my setup and deployment project the manifest doesn't install. How do I make it copy the manifest too? Or is there any other way I can tell vista to throw an error instead of redirecting files when I try to save them in the program files directory?
Answers
On the build question, the obvious question is when the post-build process runs. If it runs after the setup project then it is clearly too late bexause the MSI file has already been built. When I do this kind of thing I insert an empty C++ project because they have better post-build features, so you'd build your C# exe, run the post-build, then build the setup project. Yes, it could be your post build step being wrong. I can't help with macro choices, but I believe $(TargetPath) is always the full path to the built exe.
I'm not sure what what you're getting at with the default manifest post. That seems to be the same embedding question as this thread. Whether your manifested program throws an error or not is tough to answer because I don't understand the scenario.
Phil Wilson- Proposed As Answer byAland LiMSFT, ModeratorThursday, November 05, 2009 9:47 AM
- Unproposed As Answer byScottyDoesKnow Thursday, November 05, 2009 3:19 PM
- Marked As Answer byAland LiMSFT, ModeratorTuesday, November 10, 2009 3:32 AM
- Have you seen this:
http://community.bartdesmet.net/blogs/bart/archive/2006/10/28/Windows-Vista-_2D00_-Demand-UAC-elevation-for-an-application-by-adding-a-manifest-using-mt.exe.aspx
Phil Wilson- Marked As Answer byAland LiMSFT, ModeratorTuesday, November 10, 2009 3:32 AM
All Replies
- I'm pretty sure that mt.exe command line adds the manifest to your resources inside the exe. If you run VS 2008 and do a file open of the binary, look at resources, you should see an RT_MANIFEST there (I think that's what it's called). The file is already an external manifest, and you're embedding it in the code file.
Phil Wilson - Ya it is there, but then how come it doesn't throw an error when I try to create a file in a restricted directory? I thought the manifest told vista my program knows about it and to not mess around with the paths. If I try to do it by running it through visual studio it tells me I can't save there and asks if I want it redirected, if I run it after it's installed it redirects without telling me.
- OK I just checked again, the one in the bin of my project has the manifest in the exe, the installed one doesn't. So is the exe put into the setup msi and the post build event can't be run on it?
[Edit] Or would it be something with the target location? Maybe –outputresource:"$(TargetDir)$(TargetFileName)" doesn't work with the setup? It turns out I don't really need any of this, I can just use a default manifest. But that's not working for one of my projects. Details here:
http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/522b309f-c4bd-4c44-a67d-7d435a39164aOn the build question, the obvious question is when the post-build process runs. If it runs after the setup project then it is clearly too late bexause the MSI file has already been built. When I do this kind of thing I insert an empty C++ project because they have better post-build features, so you'd build your C# exe, run the post-build, then build the setup project. Yes, it could be your post build step being wrong. I can't help with macro choices, but I believe $(TargetPath) is always the full path to the built exe.
I'm not sure what what you're getting at with the default manifest post. That seems to be the same embedding question as this thread. Whether your manifested program throws an error or not is tough to answer because I don't understand the scenario.
Phil Wilson- Proposed As Answer byAland LiMSFT, ModeratorThursday, November 05, 2009 9:47 AM
- Unproposed As Answer byScottyDoesKnow Thursday, November 05, 2009 3:19 PM
- Marked As Answer byAland LiMSFT, ModeratorTuesday, November 10, 2009 3:32 AM
- Ya either I have to change the outputresource to use some other variable that works with setups, or it just won't work with setups. Either way embedding the default is easier. It's in a new thread because I don't use the post-build step anymore, and the problem now isn't that it won't work with setup, it just doesn't work at all. I'm doing the basic selection of add a default manifest in the project properties and it's not adding it.
The point about the error is that I want the program to throw an error when I try to write to a directory i'm not allowed to write to. This doesn't happen without the manifest because vista virtualization kicks in. To avoid that I need the manifest, which for some reason won't embed. - Have you seen this:
http://community.bartdesmet.net/blogs/bart/archive/2006/10/28/Windows-Vista-_2D00_-Demand-UAC-elevation-for-an-application-by-adding-a-manifest-using-mt.exe.aspx
Phil Wilson- Marked As Answer byAland LiMSFT, ModeratorTuesday, November 10, 2009 3:32 AM


