自动在 .NET 可执行文件中嵌入多个图标
我基本上与这个问题有同样的问题:在 WPF EXE 中嵌入多个图标
当您在资源管理器中单击“更改图标”时,我的 .NET 2.0 WinForms 应用程序当前具有以下内容:
(来源:理查德-斯莱特。 co.uk)
我想看到什么,并且按照上面文章的建议进行一些黑客攻击,我得到了这个:
(来源:理查德-斯莱特。 co.uk)
但是,获取程序集所有版本信息的过程丢失了。我需要维护程序集中的版本信息,因为我的自动更新过程依赖于此来识别应用程序的已安装版本。
我还通过持续集成过程构建应用程序,因此我不希望有任何需要手动干预的步骤,那么这可以通过自动化方式实现吗?
I basically have the same issue as this question: Embed multiple icons in WPF EXE
My .NET 2.0 WinForms application currently has this when you click "Change Icon" in explorer:
(source: richard-slater.co.uk)
What I would like to see, and with some hacking about as suggested by the above article I get this:
(source: richard-slater.co.uk)
However the process of getting there all of the version information for the assembly is lost. I need to maintain the Version Information in the assembly as my auto-update process relies on this to identify the installed version of the application.
I also build the application through a continuous integration process so I would prefer not to have any steps that require manual intervention, so is this possible in an automated way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我刚刚创建了一个简单的工具来完成此操作,而不必弄乱 .res 文件。它是一个小型实用程序,您可以将其用作构建后事件的一部分,并允许您将特定文件夹中的所有图标文件添加到程序集中。如果我们假设您的主项目文件夹下有一个图标文件夹,您可以添加以下构建后事件:
可以在 http://einaregilsson.com/add-multiple-icons-to-a-dotnet-application/
I've just created a simple tool to do exactly this without having to mess with .res files. It is a tiny utility which you can use as part of your Post-Build event and lets you add all icon files in a particular folder to your assembly. If we assume that you have a icons folder under your main project folder you can add the following post-build event:
A further description and a download can be found at http://einaregilsson.com/add-multiple-icons-to-a-dotnet-application/
ChrisF提到的文章也会清除你的程序集版本信息。遵循该指南后,您可能想尝试使用此处描述的构建后方法 链接以嵌入清单。
编辑:
它是“方法#2 - “通用”方法(使用 mt.exe)”
The article mentioned by ChrisF will also wipe out your assembly version information. Once you follow that guide you might want to try using the post-build method described here Link to embed the manifest.
EDIT:
It is "Method #2 - The "Generic" Approach (using mt.exe)"
这篇代码项目文章介绍了如何执行此操作。
基本上,您可以向项目添加更多图标资源。
This Code Project article has a walkthrough on how to do this.
Basically you add more icon resources to the project.
对我来说,该问题的最简单解决方案是创建一个 .res 文件,其中仅包含您需要的图标(并按您的首选顺序存储它们),在项目属性中禁用主图标并合并先前准备的图标包(.res 文件)到您的最终 .exe 文件,在构建后事件中执行此操作。虽然,如果这个过程可以完全自动化并保持清单数据不变,那么最后一步需要一个外部工具(ResHacker),它允许您通过命令行执行 .res 文件合并工作(当然,Visual Studio 可以做到这一点,但据我所知,没有命令行界面可以实现它 - 如果我错了,请纠正我)。
下载空白 .res 文件 (http://www.codeproject.com/Tips/160885/How-to-Embed-Multiple-Icons-and-Color-Animated-Cur.aspx)并将其添加到您的项目< /p>
从项目中删除主图标(项目 -> 属性)
下载 ResHacker 工具 (http: //www.angusj.com/resourcehacker/)并将其放置在您想要的任何位置
将类似的行添加到您的构建后事件:
仅此而已。每次在发布模式下编译项目时,您都会在目标 .exe 文件中获得所需的图标。
For me the simplest solution to that problem is to create a .res file, which includes only icons you need (and stores them in your preferred order), disable a main icon in project properties and merge previously prepared icon pack (.res file) to your final .exe file, doing it in post-build event. Although, if this process can be fully automated and keep your manifest data unchanged, it needs in last step a external tool (ResHacker), which allow you to do a .res file merging job via command line (of course, Visual Studio can do this, but as far I know there are no command line interface to achieve it - if I'm wrong, please correct me).
Download a blank .res file (http://www.codeproject.com/Tips/160885/How-to-Embed-Multiple-Icons-and-Color-Animated-Cur.aspx) and add it to your project
Fill out previously added .res file with your icons
Remove main icon from your project (Project -> Properties)
Download a ResHacker tool (http://www.angusj.com/resourcehacker/) and place it wherever you want
Add similar line to your post-build event:
That's all. Everytime you compile your project in Release mode you will get a wanted icons to your destination .exe file.