Reputation: 58
I have a C# WPF application. It has two icon files as resources - one for use when creating a release build, and the other for test builds. It is currently using 4.7.2 - but I am are planning to migrate it to .NET Core soon.
When I am generating a build, I set the icon file via the Properties-Application page.
Since I can't find a way to conditionally set the desktop icon file reliably when building, I thought I would simply check the icon file at runtime to see if it is the correct one for the build type. I do not want to have the wrong icon file used.
Why do I care? There are a number of users who might have the test and live version on their desktop at the same time. I want to make sure that the test versions can not be confused with the live version.
It may not seem like much, but often, support people remote in and most of them won't know about the test version - hence the need to avoid any confusion.
If you have a better way to set the desktop than setting the icon at build time, that would be appreciated too.
I can get the icon using ExtractAssocatedIcon() - but that doesn't indicate the name of the icon file.
Upvotes: 0
Views: 237
Reputation: 96
You could do the following to set the icon at build time.
Here are some steps:
Create your project and add your .ico
files.
Right click the project and select Unload Project
.
Right click the unloaded project and select Edit Project File
.
Inside of the project file there will be <PropertyGroup>
xml tags for your various builds.
Set the <ApplicationIcon>
xml element for each build configuration.
Now when you run the build in either Debug
or Release
the .ico
file that is used will change.
Upvotes: 1