Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I create a desktop icon for a ClickOnce application?

I have read in some of the ClickOnce posts that ClickOnce does not allow you to create a desktop icon for you application. Is there any way around this?

like image 686
Veldmuis Avatar asked Sep 30 '08 08:09

Veldmuis


People also ask

How do I create a desktop icon for an app?

Click the Windows key, and then browse to the Office program for which you want to create a desktop shortcut. Right-click the program name or tile, and then select Open file location. Right-click the program name, and then click Send To > Desktop (Create shortcut). A shortcut for the program appears on your desktop.

Where are ClickOnce applications stored?

Every ClickOnce application installed on a local computer has a data directory, stored in the user's Documents and Settings folder.

How do I create an icon on my desktop for a website?

How to Create a Desktop Shortcut to a Website Using Chrome. To create a desktop shortcut to a website using Google Chrome, go to a website and click the three-dot icon in the top-right corner of your browser window. Then go to More tools > Create shortcut. Finally, name your shortcut and click Create.

How do I publish my ClickOnce application?

Publishing with ClickOnce. In Solution Explorer, right-click the project and choose Publish (or use the Build > Publish menu item).


2 Answers

It seems like there is a way to place an icon on the desktop in ClickOnce.

  1. Upgrade to Visual Studio 2008 SP 1, and there will be a placed an icon on the desktop check box in the options page of the publish section of the project properties window.
  2. The second option is to add code to your application that copies the shortcut to the desktop on the first run of the application. See the blog post How to add Desktop Shortcut to ClickOnce Deployment Application.
like image 160
FryHard Avatar answered Sep 20 '22 04:09

FryHard


In Visual Studio 2005, ClickOnce does not have the ability to create a desktop icon, but it is now available in Visual Studio 2008 SP1. In Visual Studio 2005, you can use the following code to create a desktop icon for you when the application starts.

I have used this code over several projects for a couple of months now without any problem. I must say that all my applications have been deployed over an intranet in a controlled environment. Also, the icon is not removed when the application is uninstalled. This code creates a shortcut to the shortcut on the start menu that ClickOnce creates.

private void CreateDesktopIcon() {     ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;          if (ad.IsFirstRun)         {             Assembly assembly = Assembly.GetEntryAssembly();             string company = string.Empty;             string description = string.Empty;              if (Attribute.IsDefined(assembly, typeof(AssemblyCompanyAttribute)))             {                 AssemblyCompanyAttribute ascompany =                   (AssemblyCompanyAttribute)Attribute.GetCustomAttribute(                     assembly, typeof(AssemblyCompanyAttribute));                  company = ascompany.Company;             }             if (Attribute.IsDefined(assembly, typeof(AssemblyDescriptionAttribute)))             {                 AssemblyDescriptionAttribute asdescription =                   (AssemblyDescriptionAttribute)Attribute.GetCustomAttribute(                     assembly, typeof(AssemblyDescriptionAttribute));                  description = asdescription.Description;             }             if (!string.IsNullOrEmpty(company))             {                 string desktopPath = string.Empty;                 desktopPath = string.Concat(                                 Environment.GetFolderPath(Environment.SpecialFolder.Desktop),                                 "\\",                                 description,                                 ".appref-ms");                  string shortcutName = string.Empty;                 shortcutName = string.Concat(                                  Environment.GetFolderPath(Environment.SpecialFolder.Programs),                                  "\\",                                  company,                                  "\\",                                  description,                                  ".appref-ms");                  System.IO.File.Copy(shortcutName, desktopPath, true);             }         }     } } 
like image 43
Timo Avatar answered Sep 22 '22 04:09

Timo