Eric
Eric

Reputation: 343

Customize the "Update at Statup" capability of ClickOnce

I am working on customizing the ClickOnce deployment of our WPF application and I wanted to make sure I was not missing something about the process. As far as I know ClickOnce will handle installing the application, and optionally check for updates at startup, and also optionally check for updates on a set interval after the application starts. This can all be done without any custom code or customizations.

If we wanted to we can customize the installation process by writing our own “installation” program. It can be a standard WPF application that uses the following Walkthrough. This is a separate project from the application that is being installed.

Walkthrough: Creating a Custom Installer for a ClickOnce Application

We can so build a “Check for Updates Now” capability by implementing the code in the following walkthrough.

How to: Check for Application Updates Programmatically Using the ClickOnce Deployment API

What I am not sure about is can we customize the part where ClickOnce checks for updates at startup as the user clicks the shortcut to open the application? I like the idea of checking for updates each time the user opens the application but I would like to totally customize the process. As far as I can tell there does not seem to be a way to customize the part where ClickOnce checks for updates at startup. Can someone please verify that?

If it’s not possible to customize the “update at startup” process then one alternative I see is to not use ClickOnce at all and write our own custom code to handle installing, checking for updates at startup, and checking for updates while the application is running.

There are some other posts on SO that asked a similar question like this one.

Customize clickonce download screen

My Application does have a dynamic splash screen. Could I change that splash screen to show messages like Checking for updates… and if none are found then continue to load the application. If updates are found then force the application to restart? The down side here is that we would see the splash screen twice.

If it were my own custom process then I would have two EXEs, one would be MyApplicatoinUpdate.exe and the second would be MyApplication.exe. The shortcut would launch MyApplicationUpdate.exe to perform Checking for updates and if some are found then download them (the files are not in use yet). If no updates are found then launch MyApplication.exe and have MyApplicationUpdate.exe shut it self down. Finally to update the updater put that logic in the MyApplication.exe. Not sure if ClickOnce will allow me to customize it that far.

Thanks, -eric

Upvotes: 1

Views: 1649

Answers (1)

Walter Wilfinger
Walter Wilfinger

Reputation: 161

You can set your WPF application to not use automatic updating. That setting is in the project properties under Publish -> Updates... -> (uncheck) The application should check for updates. With that setting disabled, it's up to you to write code for how you want to check and download updates.

See the example at the bottom of this page for asynchronously checking for a ClickOnce update. You can use this as scaffolding to build your own updating logic.

So yes, you can customize the process, but you are limited to the callbacks that you get from the ClickOnce API.

You can use the async callbacks to update information on your splash screen. Yes you'd have the restart, but this is how a lot of commercial launcher/updaters behave. If updates aren't critical, you could wait for the next time the user restarts the program. That's how the Chrome browser does its updates.

The other SO question you linked to was about presentation during a first time installation. If it's important to you to not show the default UI during this first run, you'll have to write an app that the user would download and run. That app would use InPlaceHostingManager to programmatically download your 'real' application while showing your custom UI.

If you don't care about the default UI during first time install, you can put the update logic in your main app and avoid two .exes. If it's really important not show the default UI, you'll have to go with the two .exe solution.

Upvotes: 1

Related Questions