locked
Create desktop shortcut option in ClickOnce deployment is disabled RRS feed

  • Question

  • Hi,

    I have an app written in Visual studio 2008 + SP1 installed. The "Create desktop shortcut" displayed in the Manifest window but it is disabled.
    What do I need to do to enable it?

    Thanks,
    Saturday, September 19, 2009 1:17 PM

Answers

  • Have you compiled your project with .net framework 3.5.

    I found that Create Shortcut checkbox is only enabled if project is compiled with .Net Framework 3.5
    • Proposed as answer by Tamer Oz Saturday, September 19, 2009 5:08 PM
    • Marked as answer by tlu Sunday, September 20, 2009 4:32 AM
    Saturday, September 19, 2009 2:12 PM

All replies

  • I don't know the reason of problem and I was not able to reproduce it ,as an alternative way you can create shortcut within code using this method

     private void CreateShortcut(Environment.SpecialFolder f, string linkName)
            {
                IWshRuntimeLibrary.IWshShortcut sc
                WshShell w = new WshShell();
                sc = (IWshShortcut)w.CreateShortcut(Environment.GetFolderPath(f) + linkName);
                sc.TargetPath = Application.ExecutablePath;
                sc.Description = "My First Shortcut.";
                sc.IconLocation = Application.StartupPath + @"\1.ico";
                sc.Save();
            }

    I'll be also looking for a better solution to your problem directly
    Saturday, September 19, 2009 2:07 PM
  • Have you compiled your project with .net framework 3.5.

    I found that Create Shortcut checkbox is only enabled if project is compiled with .Net Framework 3.5
    • Proposed as answer by Tamer Oz Saturday, September 19, 2009 5:08 PM
    • Marked as answer by tlu Sunday, September 20, 2009 4:32 AM
    Saturday, September 19, 2009 2:12 PM
  • Where do I execute this section if I want to do it this way?

    Thanks,
    Sunday, September 20, 2009 4:35 AM
  • You can write the code below to the load event of your first form opens in application, or into program.cs.

                if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed)// check if published by clickonce
                {
                    System.Deployment.Application.ApplicationDeployment ad = System.Deployment.Application.ApplicationDeployment.CurrentDeployment;
                    if (ad.IsFirstRun)//is first run
                    {
                        CreateShortcut(Environment.SpecialFolder.Desktop, "My App Shortcut");
                    }
                }
    Sunday, September 20, 2009 4:52 AM
  • You shouldn't use the code posted above. It will create a link to the exe file, and the application will not run as a ClickOnce application, which means it won't get any updates, it won't verify that the deployment hasn't been messed around with, and anything you happen to within the ApplicationDeployment namespace will not work.

    This article shows you exactly how to create a ClickOnce desktop shortcut programmatically.

    http://robindotnet.wordpress.com/2009/04/07/creating-a-desktop-shortcut-for-a-click-once-application/

    RobinDotNet
    Click here to visit my ClickOnce blog!
    • Proposed as answer by Alexey Kozlov Tuesday, November 26, 2013 6:45 AM
    Sunday, September 20, 2009 6:11 PM
  • That's really a great point.

    Thanks RobinDotNet.
    Sunday, September 20, 2009 6:14 PM
  • Sunday, September 20, 2009 9:40 PM