Is it possible to add a desktop icon *conditionally*?
- I've read what I came up with on a search for "add desktop icon" including http://social.msdn.microsoft.com/Forums/en-US/winformssetup/thread/6a15329e-df6f-44c3-a2e2-bc3bbb9ba16e. (It's so long already that I'm starting a new thread.)
Is it possible to ask the user whether she wants a desktop icon created? (Environment .NET 3.5) I set "Always Create" to false but I don't see what effect that had. I read in the help file about Conditions and creating a checkbox but I'll be darned if I know how to create a checkbox in the install dialog. (And yes, I know this would turn it into a ClickTwice deployment but I hoped that would be okay with you MSFT folks.)
I'd just as soon not do it "programatically" on first execution -- that seems like an awfully complex approach to an awfully simple problem.
Charles
Answers
Hi Charles,
First, if you are using a setup & deployment package, I have no idea if you can have it ask the user if they want a desktop shortcut. BUT I would think it's pretty easy to set one up, because it's just a shortcut pointing at the exe file, and you know where that is. You'd have to do it in the code for your application of course. S&D packages are not my expertise; ClickOnce deployment is. ClickOnce shortcuts are not a shortcut pointing at the exe file; they include the installation URL and other information, and it checks for updates when it is invoked.
The options dialog under publish -- Is your application a console or desktop application? If so, when you go to the project properties on your main project and go to the publish tab and click Options, you should get a screen with four selections in a left-hand column, and details on the right. Are you seeing this?
ClickOnce deployment is a fairly simple way to deploy a desktop or console application and then perform incremental upgrades automatically. You basically deploy your application to a web server or network share, and the user installs it from there. Then when he runs the application, it checks for updates and applies them if found.
A ClickOnce application requires no administrative privileges to install, and is installed under the user's profile.
ClickOnce does not work if you want your application to run for all users, or if you really need to specify the location of the installation. Here are some links to the overview on MSDN and basic instructions on how to publish a clickonce application.
ClickOnce Overview
http://msdn2.microsoft.com/en-us/library/142dbbz4(VS.80).aspxHowTo publish a clickonce app
http://msdn2.microsoft.com/en-us/library/31kztyey(VS.80).aspxRobinDotNet
Click here to visit my ClickOnce blog!
Microsoft MVP, Client App Dev- Marked As Answer bytsrCharles Monday, November 09, 2009 11:06 PM
All Replies
I'm going to answer your question assuming you are using ClickOnce deployment rather than a setup & deployment package. IF you are using an S&D package, please post back and satte that.
First, I tried out that checkbox in the project properties to create a desktop shortcut, but didn't find it to be reliable.
This blog post gives you the code to create your own desktop shortcut for a ClickOnce application (both C# and VB).
http://robindotnet.wordpress.com/2009/04/07/creating-a-desktop-shortcut-for-a-click-once-application/
Using this, you can ask the user first, and/or let the user configure, whether they want a desktop shortcut or not.
RobinDotNet
p.s. The "once" in "clickonce" is the button you push to publish it, not the number of buttons for the user to install it. If it were the latter, I think it would be click-lots-of-times. ;-)
Click here to visit my ClickOnce blog!
Microsoft MVP, Client App Dev- Robin, thanks. Well, let me start by revealing my ignorance. Yes, I was talking about an S&D package. I was not aware of the distinction, although I did notice in my hacking around that I saw two different kinds of look-and-feel to the install package that resulted.
Okay, new questions.
1. Now that I know the difference, why should I be using one or the other? Which one is "better"? (Probably that question should be "in which situations is it better to use C/1; in which situations is it better to use S&D?")
2. I am developing a C# program in VS 2008 Pro targeting .NET 3.5. When I do what you say in the video on your blog linked above, I don't see what you show. Properties, Publish, Options brings up a somewhat smaller dialog box. There is no left-hand panel and the word "Manifest" does not appear. (Nor is there any option with "desktop" in it.) I wish I could paste the screen shot here but I guess I can't.
Charles Hi Charles,
First, if you are using a setup & deployment package, I have no idea if you can have it ask the user if they want a desktop shortcut. BUT I would think it's pretty easy to set one up, because it's just a shortcut pointing at the exe file, and you know where that is. You'd have to do it in the code for your application of course. S&D packages are not my expertise; ClickOnce deployment is. ClickOnce shortcuts are not a shortcut pointing at the exe file; they include the installation URL and other information, and it checks for updates when it is invoked.
The options dialog under publish -- Is your application a console or desktop application? If so, when you go to the project properties on your main project and go to the publish tab and click Options, you should get a screen with four selections in a left-hand column, and details on the right. Are you seeing this?
ClickOnce deployment is a fairly simple way to deploy a desktop or console application and then perform incremental upgrades automatically. You basically deploy your application to a web server or network share, and the user installs it from there. Then when he runs the application, it checks for updates and applies them if found.
A ClickOnce application requires no administrative privileges to install, and is installed under the user's profile.
ClickOnce does not work if you want your application to run for all users, or if you really need to specify the location of the installation. Here are some links to the overview on MSDN and basic instructions on how to publish a clickonce application.
ClickOnce Overview
http://msdn2.microsoft.com/en-us/library/142dbbz4(VS.80).aspxHowTo publish a clickonce app
http://msdn2.microsoft.com/en-us/library/31kztyey(VS.80).aspxRobinDotNet
Click here to visit my ClickOnce blog!
Microsoft MVP, Client App Dev- Marked As Answer bytsrCharles Monday, November 09, 2009 11:06 PM
- Robin, thanks for your help.
I guess I can live with those ClickOnce restrictions. I assume (and I will test this -- no need for an answer) that the "no choice of location" means that the location is C:\Windows\Program Files\Software Company\Product.
My application is a small WPF application. Nothing real special about it. It's tiny because it is a small administrative adjunct to a larger product the significant parts of which run on a non-Windows platform (z/OS). Doing any "one-time" processing such as adding a desktop icon is a bigger change than you might guess because currently it saves no state between runs -- no registry or similar configuation data. Every time it runs it thinks it's the first time! <g>
> four selections in a left-hand column, and details on the right. Are you seeing this?
In a word, No. Again, WPF application, VS Pro 2008, C#.NET. I double-click on Properties under the main project (not the S&D project). That opens a tab with a title of the application name. It is two columns, with the left column saying Application, Build, Build Events ... Security, Publish. If I click on Publish I get a panel that starts with two diabled combos, Configuration: N/A and Platform: N/A. Then Publish location and then Install Mode and Setting and finally Publish Version. There are four buttons on the right: Application Files..., Prerequisities..., Updates..., and Options.... I click on Options... and it brings up a SINGLE-PANEL dialog box titled Publish Options. The fields are Publish Language, Publisher name, Product name, Support URL, and Deployment Web page, followed by eight checkboxes (one disabled) none of which refer to icons or the desktop or anything real similar.
Now what?
Charles - > I guess ... the location is C:\Windows\Program Files\Software Company\Product [Actually, "\Windows" should not be in there]
No, ClickOnce appears to install an application in its own little private magic place, something like
C:\Documents and Settings\User Name\Local Settings\Apps\2.0\C8HZ6ZC1.DG0\CL8
E4DRX.50L\clou..tion_9ccbd82a05f08200_0001.0000_a8d9c88086126ecd>
Charles - With a setup and deployment MSI project it's difficult to do this. The file and the shortcut are not separate, they're in the same internal installer component, so if you get the file then you get the shortcut. VS setups aren't fully-featured by design, and they hide the complexity of the internal component structure. I think you could do this by adding the file twice, one with a shortcut and one without. Depending on the edit box choose one or the other as a condition on the file, nd the shortcut will follow.
Phil Wilson - First, thanks to some off-line help (you know who you are <g>) I now know that the reason I was not seeing what others are seeing was a lack of SP1 installed for VS 2008 Pro. I now have SP1 installed and see the dialog box as RobinDotNet described it. I'm going to hack around with this some and see what I think.
At this point I'm leaning toward using S&D rather than ClickOnce. I'm a little put off by the installation in the "magic" ClickOnce location rather than Program Files. As a user I like knowing where things are installed. You can track down a component that is running in TaskManager and see what product it is part of. It's easy to see what's installed and what is not (what's REALLY there, not what Add/Remove Programs thinks). It's easy to create shortcuts for a taskbar. It's easy to see if an uninstall has really done its job 100%. (Perhaps I'm just living in the past.)
I find it interesting to note that of the about half a zillion products that I have installed on this machine, apparently not one was a ClickOnce install. There is nothing in Docs & Settings\...\Apps other than my one test install.
@PhilWilson, I'm not really sure what you mean. It's fairly trivial to add a desktop icon install (see the thread I reference on my OP). But how during the install do I ask the user whether he wants to do it or not? Perhaps I'm just not understanding what you mean. What edit box are you referring to in your last sentence?
Charles Hi Charles,
One of the primary design goals of ClickOnce deployment is to be able to install applications without having to have administrative privileges. That is why the application is installed in the user's profile under obfuscated folders. In Vista (and Windows Fabulous), you can't write to Program Files anyway, so I'm not sure why you would care where your application ended up...
If you want to cache data that is retained when the ClickOnce application is updated (and make it available to other applications if you want to), you simply put it in ApplicationData. (There is an article on my blog about this.)
ClickOnce apps are not run by the user invoking the exe file; they are run by the shortcut being invoked, which contacts the server to check for updates. (Hence the article on my blog about creating a desktop shortcut by copying the one from the start menu to the desktop). The exe does show up in the Task Manager, and if you name it appropriately, you should be able to figure out which one is yours. ;-)
As for installing/uninstalling, the only folders that the ClickOnce deployment actually impacts are under the user's profile. We have found that we can deploy most assemblies locally (such as DirectX and SQLCE), which gives us control over what version of the 3rd party dll's we are using.
Dell uses ClickOnce for one of their applications (I apparently have it installed, but I am too tired to go figure out what it is, probably their update downloader), GoToMeeting uses ClickOnce (or some variant thereof), and it looks a lot like Google uses it for their applications as well. Microsoft uses it internally for their HR apps, etc., to their thousands of employees. And of course, my company uses it (GoldMail).
The best thing about ClickOnce is the automatic incremental updates. With ClickOnce, you can make sure that your users are always running the most current version. You simply re-publish the next version and set the minimum version number to the current one, and it will automatically install when the user runs the application. DLLs that are strongly named will not be copied across the network again; they will be retrieved from ClickOnce's local cache.
Having said that, you can't use ClickOnce deployment for windows services, web services, web applications, etc. It is for desktop applications. You also won't want to use it if where your application is installed IS important to you for some reason. If you want to pass in parameters, you have to make the application online-only and invoke the installtion URL with query parameters, you can't just run the exe file and pass in the parameters. And ClickOnce applications generally do not require administrative privileges to run, but I think with a bit of cleverness, you can override that. ClickOnce deployments are easy to set up and use.
That's my two cents' worth. You can always try it, and if you don't like it, stick with the S&D packages. S&D packages also have more flexibility, more control over the installation dialogs, etc.
Good luck with it, whichever way you decide to go!
RobinDotNet
Click here to visit my ClickOnce blog!
Microsoft MVP, Client App Dev- Thank you all. @RobinDotNet, you are the best!
I hear you on the automatic updates. ClickOnce sounds very cool. I think I'm going o go with S&D, however. I don't need the automatic updates -- the predecessor to this little app was totally stable -- and so I'm going to avoid the complexity and "magic" of ClickOnce.
I'm going to start a new thread on some general thoughts on Setup & Deployment.
Charles - I should get back here and say I solved the conditional desktop icon problem. I'm talking about S&D here -- I think ClickOnce .NET 3.5 will do this automatically as RobinDotNet says in a post above, but I have not totally explored. I'm going to post this as several disjoint links because otherwise the instructions would be long and I don't really have the time.
1. Add a desktop icon install if you have not done so already. This http://support.microsoft.com/kb/837220 is a pretty good discussion. It will install unconditionally.
2. Add a checkbox dialog to your installation wizard. Follow the instructions about halfway down the page under Adding a Custom Installation Dialog Box here http://msdn.microsoft.com/en-us/library/k3bb4tfd(VS.80).aspx. Obviously, you would want to change the text. Make the banner text something like "Add desktop icon?" and BodyText something like "This checkbox controls whether or not to create a shortcut to blah blah on your desktop." Set the default (checked or not) that you want. BE SURE TO SET THE VISIBILITY TO FALSE ON THE LAST THREE CHECKBOXES OR YOU WILL HAVE THREE STUPID ORPHAN CHECKBOXES ON YOUR DIALOG.
3. Now make the desktop icon install conditional on the checkbox. Go to the File System tab and get to the properties of User's Desktop. Make the Condition property be CHECKBOXA1=1
That should do it. Good luck!
Charles


