简体   繁体   中英

Visual Studio Installer Project - shortcut icons not set

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!

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

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.

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.

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.

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

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

I had the same issue, and solved thanks bytecode77's answer: the problem was that the images were PNG converted.

To solve the problem I used https://redketchup.io/icon-editor It allowed me to

  • upload my.ico file
  • see all images, in size and formats
  • convert images from PNG to BMP (32-bit)
  • download the up-to-date.ico file

Apparently, BMP format is allowed up to 256x256px images only; my.ico file also contained a 512x512px size, I left it as PNG, but kept working.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM