问题描述:

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:

EVEMon Single Icon http://www.richard-slater.co.uk/wp-content/uploads/2010/08/EVEMonIconsWhatIHave.png

What I would like to see, and with some hacking about as suggested by the above article I get this:

EVEMon Multiple Icons http://www.richard-slater.co.uk/wp-content/uploads/2010/08/EVEMonIconsWhatIWant.png

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?

网友答案:

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:

C:\path\to\InsertIcons.exe $(TargetPath) $(ProjectDir)icons

A further description and a download can be found at http://einaregilsson.com/add-multiple-icons-to-a-dotnet-application/

网友答案:

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 http://blogs.msdn.com/b/cheller/archive/2006/08/24/718757.aspx 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.

网友答案:

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).

  1. 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

  2. Fill out previously added .res file with your icons

  3. Remove main icon from your project (Project -> Properties)

  4. Download a ResHacker tool (http://www.angusj.com/resourcehacker/) and place it wherever you want

  5. Add similar line to your post-build event:

    if $(ConfigurationName) == Release (
      ..\..\..\..\..\Tools\ResHack\ResHacker.exe -add $(TargetPath), $(TargetPath), $(ProjectDir)Properties\AssemblyWin32.res ,,,
    )
    

That's all. Everytime you compile your project in Release mode you will get a wanted icons to your destination .exe file.

相关阅读:
Top