Visual Studio Setup Project - Use exe Icon for installed Shortcuts

岁酱吖の 提交于 2020-01-04 09:12:35

问题


I have a Application that is deployed to client machines with a Visual Studio 2010 Setup Project. My App creates a Desktop Shortcut to the main exe file.

If I open the shortcut's properties and choose "change icon" I see that the icon used for the shortcut is something like:

%SystemRoot%\Installer\{5B821236-4F7A-4AC9-8BA6-441F456F12F0}\_83771230001D45618121E3.exe

Hoever, I want it to be

%Program Files%\MyCompany\MyApp\MyApp.exe

or

%Program Files%\MyCompany\MyApp\MyIcon.ico

Is there a way to achive that?

I already use a pice of Javascript that modifies my setup in a PostBuild Step to add

DISABLEADVTSHORTCUTS =  1

to the properties table in the Setup file. Maybe the solution is similar, but I don't know what to change.


回答1:


The real issue seems to be a bug in the Setup Project creating only low quality (48x48 px max) icons and has been confirmed by Microsoft but not been fixed until now.

See http://connect.microsoft.com/VisualStudio/feedback/details/540424/setup-deployment-project-creates-poor-defaulticon-for-file-type

You can fix this by editing the *.msi file with Orca:

  1. Look at the Shortcut Table, find the Desktop Shortcut, remember the Icon_ value.

  2. Go to the Icon Table, wich contains entrys with a Name and a Data column. Locate the right Icon, Double Click the [Binary Data] entry and browse for your high resolution icon.

Unfortunatly you have to do this everytime you recreate the setup project, but at least you have a good result. If I have some spare time I will try to automate the process and update this post.




回答2:


Shortcuts created by Windows Installer automatically use a resource from Windows Installer cache ("C:\Windows\Installer" folder). This is the normal behavior and it's usually not a problem. So you could just ignore it.

However, if you really want to set a custom icon path, you can try using a custom action to create the shortcut manually.



来源:https://stackoverflow.com/questions/6758171/visual-studio-setup-project-use-exe-icon-for-installed-shortcuts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!