Visual Studio Installer Project - shortcut icons not set
Asked Answered
Y

6

14

I've created a WinForm application with .NET 4.6.1 and C#. I'm using Visual Studio 2017, with latest fixes updated (up to 29-Sept-2018). The application uses a custom icon, and it's correctly shown: exe file is displayed with the proper icon.

I've created an Installer Project using the "Microsoft Visual Studio 2017 Installer Projects" extension. The installer copies sets of files in different locations (under Program Files, under the user's App Data, etc), and the files are correctly copied. EXE files correctly display the custom icon I've set.

Now, here comes the problem. I've set a shortcut on the desktop. The shortcut is created and actually works, but the icon is wrong: the default windows icon is shown instead. I've tried several solutions and read from several forums.

1- I've tried to "Create New Shortcut" from the File System view (Desktop folder), and then set the Icon from the Properties window.

2- I've tried to right-click the output exe and select "Create a shortcut to primary output", and then dragged the shortcut to the desktop folder.

3- I've tried to select the icon referencing directly the Application Output exe: the wizard allows me to select the correct icon, I select it and confirm.

4- I've tried to select the icon referencing the source ICO file: once again, the wizard allows me to select the correct icon, I select it and confirm.

Any solution I've tried, I ALWAYS obtain a shortcut displayed with the default icon and NOT with the custom icon.

Whatsmore, if I try to manually "Create a shortcut" by right-clicking on the EXE, in window's File Explorer, the shortcut is created using the correct custom icon! So, it's strange that Visual Studio (or the installer) is not able to do the same thing during the installation.

Do you have any idea of the cause of the problem, and how to fix it?

Thanks!

Your answered 29/9, 2018 at 10:42 Comment(1)
I couldn't reproduce your problem. Point 1 of your list worked for me, selecting an .ico file from the application folder.Narcissus
P
27

I had the same issue, and tried every combination the OP also tried.

In the end my issue was down to the fact my .ICO file did not have the correctly sized images for the desktop shortcut. (It would have been nice if Visual Studio had told me that!!!!)

Oddly like the OP generating a shortcut by hand did make the icon appear, so I find the above a bit strange!

Anyway I was generating my .ICO file using GIMP to convert a PNG. I had clearly got this stage wrong.

I'd suggest trying a different .ICO file first and see if that is the cause.

It was for me and I solved it by using the following site:

http://icoconvert.com/

I then ticked the relevant boxes for the sizes, used this new .ICO file and hey presto it all works

Proprietress answered 11/12, 2018 at 10:11 Comment(5)
I have found out it was exactly the same issue in my case too! Just adjusting the ICO file to a standard resolution (I used 48x48 IIRC) fixed the issue! So, as long as I'm concerned, I'm marking this as the correct answer.Your
i had similar issue, found that my ico file was 256x256. Converted it to 64x64 and it worked.Broncobuster
Dude you did not mention the size.Inadvertent
Thanks, my solution was, to use a PNG2ICO generator, which supports multi size icons, and select all sizesAnastasio
as the IcoConvert page is not available anymore, this works well: redketchup.io/icon-editorCorrinacorrine
C
4

I had the same problem, using VS 2019 with the Visual Studio Installer extension. I checked my icon had the correct dimensions (16x16, 32x32 and 48x48 within the ICO file), so it wasn't this.

Also, I had previously installed the app and the icon had worked fine. I'm using the "replace previous version", but I'm not sure if this is cause.

I double-checked the installers Outputs, and yes, the .ico was being copied/included... however I found that the defined shortcut (in VSI editor) did not have the icon property defined anymore - it had reverted to "(None)". 1

I resolved it in VSI, by using the Properties window for the shortcut, on the Icon property, select Browse from the DDL, then set the .ico from the source file. (The VSI detail tab still shows the default "text doc" icon, but result after install is the one I wanted/selected).

This is not the first time VSI has done this to my projects, so I'm guessing it is a slight bug of this otherwise great extension.

Carrageen answered 26/3, 2020 at 16:38 Comment(0)
O
3

I'd the same problem. I had fix it simply select the main ouput (.exe) and not the .ico in the shortcut property icon option. I suppose installer not recognize the .ico file correctly.

Olympias answered 16/12, 2018 at 20:5 Comment(0)
C
3

I encountered the same problem. Just ensure you set the icon for the project to the same icon file as for the desktop shortcut and user program shortcut.

The icon file must follow the dimensions of Windows 7. You can use http://icoconvert.com/ for changing the icon dimensions.

Consignee answered 7/2, 2020 at 12:43 Comment(2)
Heyy, I was not intending to duplicate the answer above I was describing how I solved my problem as if you visit the website above the have a various format and i had got confused, so I used all of them, to avoid someone making the mistake that i made. I am sorry if it seems as a duplicate.Consignee
I was using this to understand icons in windows: learn.microsoft.com/en-us/windows/win32/uxguide/vis-iconsConsignee
P
2

The problem for me was that the .ico was compressed with PNG.

Do not export using Vista PNG compression! Use normal BMP frames instead.

Propagable answered 23/7, 2022 at 17:16 Comment(0)
P
0

No solution described above worked for me, including the commercial web convertor.

Finally, I read this in the MS documentation about createing ICO files:

In order to display properly in Windows Explorer, ICO files must be saved-down to 24-bit and 8-bit color depths for each image size.

It seems to be related, because when I set all 3 images within ICO (16x16, 32x32, 64x64) to 24b depth, the resulting 37 KB file worked and icon started to show on the desktop. No compression used. And I did it in GIMP, so it's not a GIMP issue, but the settings. And it works for both Installed and Installer project output.

Preindicate answered 11/9, 2023 at 11:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.