Does anyone know how to add a custom icon to a c# project, so that after it is packaged then users install the application, the custom icon (instead of the default one) will be displayed on desktop?
Here is one solution:
1.On the Project Properties->Add ->Add Existing Item.
2. Browse the .ico file to locate it or have it already copied into the project directory.
3. Now in solution explorer you should have that file, let say myfile.ico.
4. Right Click on myfile.ico ->Properties -> Build Action -> Embedded Resource
5. In the code :
mainForm.Icon = new Icon(Assembly.GetExecutingAssembly().GetManifestResourceStream("YourAssembly.myfile.ico"), 16, 16);
6. Build the project
7. Create a installer project Setup and Deployment Projects->Setup, give a name and location.
8. Set the File System on Target machine entries:
- Application Folder - add the exe and other required files such dll, .config etc
- User's Desktop - name the shortcut to be be displayed on the desktop. Set the following properties: Icon (browse myfile.ico), Target - the exe file ...
- User's Programs Menu - name the entry to be displayed in Start->All Programs . Set the following properties: Icon (browse myfile.ico), Target - the exe file ...
Be sure to set AlwaysCreate to True for the the User's Desktop and User's Programs Menu entries.
9. Build the installer project
10. Under My Project Installer/Debug or /My Project Installer/Release , there are created Setup.exe, My Project Installer.msi and Setup.ini which are used now to install the project.
-obislavu-
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.