I spent ages looking for a solution to this. Amazing, really, as it must be the case for all Visual Studio installer projects.
I'm using Visual Studio 2017 Community at the time of writing and I can't see any option to do this from within the IDE.
Apparently this is an issue with the resulting .msi
where the shortcut created is an "advertising shortcut". I'll leave you to discover what you want to know about that in your own time. (Personally, I don't care.)
What you need to do is force the shortcut to be "non-advertising".
This is the better of the two solutions I've found squirreled away in SO. I think it's better because it 1) doesn't include adjusting your installer project for each solution and 2) doesn't involved manually editing the .msi
file after every build.
Full credit to the guys on this SO post for this solution, btw. You know who you are. I'm posting because it's not obvious from the question that it will solve this particular problem.
What you do is make a generic change to the msi creation schema file so that the change propagates to all of your future builds. You'll need Orca to make the initial change.
Download the Windows SDK Installer here.
Select "MSI Tools" in the installer.
Install Orca-x86_en-us found in {Installation Folder}Windows Kits10WindowsSDKInstallers.
Find the file "Schema.msi" which is located somewhere like {Visual Studio Program Folder}Common7IDECommonExtensionsMicrosoftVSIinVsdSchema.
Open "Schema.msi" in Orca.
Copy the folder to the Desktop if it is read only and replace the original after step 9.
Select the "Property" table on the left.
Add a table row with property DISABLEADVTSHORTCUTS
and value "1" (true).
Save the file and close Orca.
Rebuild your installer project and (re-)deploy your application.
Enjoy the ability to "Run as administrator"!
A final note: I've found that updates to Visual Studio can overwrite the change you've made, once again removing the "Run as Administrator" context option. So check the msi file after each update.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…