How can I roll back the ClickOnce application?

Is there a way (hacky will do) that allows the user to revert to the previous ClickOnce version of the deployed application

I looked through the docs and APIs, and it doesn't seem to be that way. You can selectively choose whether you want to update, but after the update, there seems to be no turning back.

+42
clickonce
Oct 13 '08 at 22:57
source share
8 answers

ClickOnce will use any version you submit to them. If you send them an old version, they will roll back to that old version.

Back in May, my friend David wrote an article on how to do this for each user. We can literally have each user in a different version. The application even tells the database which version the user wants, so they could theoretically change their version, and then simply restart the application.

Fine Grained Versioning with ClickOnce

+17
Oct 13 '08 at 23:20
source share

You can revert to the old server-side version by modifying the server manifest file. When the client restarts the application, he will see that he has a different version than what the server says, this is the "current" version, and it will download a new one. This server manifest file usually always points to the latest version, but this is optional.

Here's how to change it (I published using Visual Studio 2008. Other versions may have a different publication folder structure).

In the same folder as publish.htm, there is an XML document called [appName].application . This is a server-side manifest file that the client uses to compare the current version. This document contains the current version in which the client should work, as well as the location on the server that can be found in the deployment files.

In the same place as publish.htm , the Application Files folder is also located. This folder contains subfolders for each of the previous editions. Inside each of these subfolders is a different XML document with the same name that I mentioned above, called [appName].application . Copy this file (from any folder containing the version you want to go back to) and paste it into the same folder as publish.htm (several levels up). When the client application restarts, it will appear just like the new version is available, download it and run it. Now the client will work with the previous version.

+75
Nov 02 '09 at 22:24
source share

You can enter the Add / Remove Application application and select your application and choose to install the latest installation.

+5
Oct 13 '08 at 22:59
source share

You can use MAGEUI to roll back to a previous version of the manifest on the server. Check it out .

+2
Oct 13 '08 at 23:29
source share

If you look at your deployment location, you will see each previous version in a separate folder with the added version number, as well as the deployment manifest, as well as with the added version number.

You can rename any of them as the current deployment, and the next time you update this application, it will pull the version that you returned to.

+1
Oct 13 '08 at 23:16
source share

I understand that the ClickOnce versioning algorithm looks like this:

  • If the version installed on the client = the version deployed on the server does nothing
  • If client version <server version - update
  • If client version> server version:
    • If minimumVersion is indicated on the client> = server version - show an error, since we have
    • If the minimum value indicated on the client is <server version - downgrade
    • If MinimumVersion is not indicated on the client - downgrade
+1
Sep 24 '13 at 15:55
source share

I just needed to make one of them on my live server, and it was nice to have all these notes. My solution was a little different and I wanted to add this as a fix. Before I begin the deployment, I always back up the entire containing folder. I was able to copy the entire folder structure back to its original state, and everything worked fine.

Notes on this with caution:

  • Your backup will be large if the application is quite large or there are many versions already published in the application file folder. Make sure you have enough space (there are no objects for me).
  • Permissions have an unpleasant tendency to bite you this way. Make sure your deployment location is located for external access and you verify all permissions before and after recovery.
  • It was useful for me to recycle my application pool in IIS .
0
Feb 22 '12 at 17:37
source share

This can be done using reflection if you know the URI publisher and name, the public key public key token, and the processor architecture as the deployment and application.

The code below will attempt to cancel the "coolapp.app" ClickOnce application. If he cannot rollback, he will try to remove it.

 using System; using System.Deployment.Application; using System.Reflection; namespace ClickOnceAppRollback { static class Program { /// <summary> /// The main entry point for the application. /// </summary> static void Main() { string appId = string.Format("{0}#{1}, Version={2}, Culture={3}, PublicKeyToken={4}, processorArchitecture={5}/{6}, Version={7}, Culture={8}, PublicKeyToken={9}, processorArchitecture={10}, type={11}", /*The URI location of the app*/@"http://www.microsoft.com/coolapp.exe.application", /*The application assemblyIdentity name*/"coolapp.app", /*The application assemblyIdentity version*/"10.8.62.17109", /*The application assemblyIdentity language*/"neutral", /*The application assemblyIdentity public Key Token*/"0000000000000000", /*The application assemblyIdentity processor architecture*/"msil", /*The deployment dependentAssembly name*/"coolapp.exe", /*The deployment dependentAssembly version*/"10.8.62.17109", /*The deployment dependentAssembly language*/"neutral", /*The deployment dependentAssembly public Key Token*/"0000000000000000", /*The deployment dependentAssembly processor architecture*/"msil", /*The deployment dependentAssembly type*/"win32"); var ctor = typeof(ApplicationDeployment).GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, null, new Type[] { typeof(string) }, null); var appDeployment = ctor.Invoke(new object[] { appId }); var subState = appDeployment.GetType().GetField("_subState", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(appDeployment); var subStore = appDeployment.GetType().GetField("_subStore", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(appDeployment); try { subStore.GetType().GetMethod("RollbackSubscription").Invoke(subStore, new object[] { subState }); } catch { subStore.GetType().GetMethod("UninstallSubscription").Invoke(subStore, new object[] { subState }); } } } } 
0
Jun 28 2018-12-12T00:
source share



All Articles