4

We decided to use the minimumRequiredVersion in our clickOnce application manifest, and now when we try to rollback to a previous version when the user launches the application it fails to start. It says the application manifest has a earlier version than the required version and the user can not use the application. We did not have this problem withou the minimumRequiredVersion, but we would like to use that.

emilam
  • 195
  • 2
  • 8

4 Answers4

8

You have to deploy a new version with a higher version number. There is no built in rollback feature.

chilltemp
  • 8,854
  • 8
  • 41
  • 46
  • This sound crazy, but after few hours of searching I came to the conclusion that it is true. To rollback, you need to release the previous binaries with an higher version number... – Thomas Nov 06 '17 at 11:03
2

You can use Mage.exe to update your deployment manifest (.application file extention) to a higher version, and select the application manifest of the previous version. Like chilltemp said, you still have to go to a higher version, but you don't have to re-deploy your code.

PJ8
  • 1,278
  • 10
  • 15
  • You have to make a copy of the _v_{0}_{1}_{2}_{3} folder you want to rollback *to* and name it a version # higher than the one you're trying to get away from, then use MageUI (or Mage, but for this example, MageUI) to point first to the .application file *in the ClickOnce root*, change the version number, have it point to the .manifest file in the new folder, then save. For me, I had to also sign the application. The "downgrade" did work, but **it did not read my previous app settings, rendering this method unusable for me**. (Not sure if I did something wrong, but that's a dealbreaker.) – Derreck Dean Dec 01 '16 at 19:08
0

This can be done via reflection if you know the publisher uri and the name, version language public key token and processor architecture of both the deployment and the application.

The below code will try to rollback the "coolapp.app" click once app. If it can't roll back, it will try to uninstall it.


using System;
using System.Deployment.Application;
using System.Reflection;

namespace ClickOnceAppRollback
{
    static class Program
    {
        /// 
        /// The main entry point for the application.
        /// 
        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's assemblyIdentity name*/"coolapp.app",
                /*The application's assemblyIdentity version*/"10.8.62.17109",
                /*The application's assemblyIdentity language*/"neutral",
                /*The application's assemblyIdentity public Key Token*/"0000000000000000",
                /*The application's assemblyIdentity processor architecture*/"msil",
                /*The deployment's dependentAssembly name*/"coolapp.exe",
                /*The deployment's dependentAssembly version*/"10.8.62.17109",
                /*The deployment's dependentAssembly language*/"neutral",
                /*The deployment's dependentAssembly public Key Token*/"0000000000000000",
                /*The deployment's dependentAssembly processor architecture*/"msil",
                /*The deployment's 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 });
            }
        }
    }
}
Hasani Blackwell
  • 2,026
  • 1
  • 13
  • 10
0

If you want to rollback the version to a previous one before the clients minimum required version then you will need to reinstall the clickonce application.

Take a look at this link to see how it can be done in code: ClickOnce and Expiring Code Signing Certificates

John Hunter
  • 4,042
  • 4
  • 26
  • 35