简体   繁体   English

Visual Studio 安装程序项目 - 未设置快捷方式图标

[英]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).我使用 .NET 4.6.1 和 C# 创建了一个 WinForm 应用程序。我使用的是 Visual Studio 2017,更新了最新的修复程序(截至 2018 年 9 月 29 日)。 The application uses a custom icon, and it's correctly shown: exe file is displayed with the proper icon.该应用程序使用自定义图标,并且显示正确:exe 文件显示有正确的图标。

I've created an Installer Project using the "Microsoft Visual Studio 2017 Installer Projects" extension.我使用“Microsoft Visual Studio 2017 安装程序项目”扩展创建了一个安装程序项目。 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.安装程序将文件集复制到不同位置(在 Program Files 下,在用户的 App Data 下等),并且文件被正确复制。 EXE files correctly display the custom icon I've set. EXE 文件正确显示我设置的自定义图标。

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.快捷方式已创建且实际有效,但图标错误:显示的是默认的 windows 图标。 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. 1- 我尝试从文件系统视图(桌面文件夹)“创建新快捷方式”,然后从属性 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. 2- 我尝试右键单击 output exe 和 select“创建主输出的快捷方式”,然后将快捷方式拖到桌面文件夹。

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. 3- 我试过 select 直接引用应用程序 Output exe 的图标:向导允许我 select 正确的图标,我 select 并确认。

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. 4- 我试过 select 引用源 ICO 文件的图标:再次,向导允许我 select 正确的图标,我 select 并确认。

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. Whatsmore,如果我尝试通过右键单击 EXE 手动“创建快捷方式”,在窗口的文件资源管理器中,快捷方式是使用正确的自定义图标创建的,所以。 it's strange that Visual Studio (or the installer) is not able to do the same thing during the installation.奇怪的是 Visual Studio(或安装程序)在安装过程中无法做同样的事情。

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.我遇到了同样的问题,并尝试了 OP 也尝试过的所有组合。

In the end my issue was down to the fact my .ICO file did not have the correctly sized images for the desktop shortcut.最后,我的问题归结为我的 .ICO 文件没有正确大小的桌面快捷方式图像。 (It would have been nice if Visual Studio had told me that!!!!) (如果 Visual Studio 告诉我,那就太好了!!!!)

Oddly like the OP generating a shortcut by hand did make the icon appear, so I find the above a bit strange!奇怪的是,手动生成快捷方式的 OP 确实使图标出现,所以我觉得上面有点奇怪!

Anyway I was generating my .ICO file using GIMP to convert a PNG.无论如何,我正在使用 GIMP 生成我的 .ICO 文件来转换 PNG。 I had clearly got this stage wrong.我显然弄错了这个阶段。

I'd suggest trying a different .ICO file first and see if that is the cause.我建议先尝试不同的 .ICO 文件,看看这是否是原因。

It was for me and I solved it by using the following site:这是给我的,我通过使用以下网站解决了这个问题:

http://icoconvert.com/ http://icoconvert.com/

I then ticked the relevant boxes for the sizes, used this new .ICO file and hey presto it all works然后我勾选了尺寸的相关框,使用了这个新的 .ICO 文件,嘿,一切正常

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.我已经修复它,只需在快捷方式属性图标选项中选择主输出(.exe)而不是 .ico。 I suppose installer not recognize the .ico file correctly.我想安装程序无法正确识别 .ico 文件。

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.图标文件必须符合 Windows 7 的尺寸。您可以使用http://icoconvert.com/更改图标尺寸。

I had the same problem, using VS 2019 with the Visual Studio Installer extension.我遇到了同样的问题,将 VS 2019 与 Visual Studio 安装程序扩展一起使用。 I checked my icon had the correct dimensions (16x16, 32x32 and 48x48 within the ICO file), so it wasn't this.我检查了我的图标有正确的尺寸(ICO 文件中的 16x16、32x32 和 48x48),所以不是这个。

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)".我仔细检查了安装程序的输出,是的,.ico 正在被复制/包含......但是我发现定义的快捷方式(在 VSI 编辑器中)不再定义图标属性 - 它已恢复为“(无)”。 1 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.我在 VSI 中解决了这个问题,通过使用快捷方式的属性窗口,在图标属性上,从 DDL 中选择浏览,然后从源文件中设置 .ico。 (The VSI detail tab still shows the default "text doc" icon, but result after install is the one I wanted/selected). (VSI 详细信息选项卡仍显示默认的“文本文档”图标,但安装后的结果是我想要/选择的那个)。

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.这不是 VSI 第一次对我的项目这样做,所以我猜这是这个本来很棒的扩展的一个小错误。

The problem for me was that the .ico was compressed with PNG.我的问题是.ico是用 PNG 压缩的。

Do not export using Vista PNG compression!不要使用 Vista PNG 压缩导出! Use normal BMP frames instead.请改用普通 BMP 帧。

I had the same issue, and solved thanks bytecode77's answer: the problem was that the images were PNG converted.我有同样的问题,并解决了感谢 bytecode77 的回答:问题是图像是 PNG 转换的。

To solve the problem I used https://redketchup.io/icon-editor It allowed me to为了解决这个问题,我使用了 https://redketchup.io/icon-editor它让我能够

  • upload my.ico file上传 my.ico 文件
  • see all images, in size and formats查看所有图像,大小和格式
  • convert images from PNG to BMP (32-bit)将图像从 PNG 转换为 BMP(32 位)
  • download the up-to-date.ico file下载 up-to-date.ico 文件

Apparently, BMP format is allowed up to 256x256px images only;显然,BMP 格式最多只允许 256x256px 的图像; my.ico file also contained a 512x512px size, I left it as PNG, but kept working. my.ico 文件还包含 512x512px 大小,我将其保留为 PNG,但继续工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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