【问题标题】:How can I rollback clickOnce if I have a minimum required version?如果我有最低要求的版本,如何回滚 clickOnce?
【发布时间】:2012-07-01 21:22:35
【问题描述】:

我们决定在 clickOnce 应用程序清单中使用 minimumRequiredVersion,现在当用户启动应用程序时我们尝试回滚到以前的版本时,它无法启动。它说应用程序清单的版本早于所需版本,用户无法使用该应用程序。如果没有 minimumRequiredVersion,我们没有这个问题,但我们想使用它。

【问题讨论】:

    标签: .net clickonce


    【解决方案1】:

    您必须部署具有更高版本号的新版本。没有内置的回滚功能。

    【讨论】:

    • 这听起来很疯狂,但经过几个小时的搜索,我得出结论,这是真的。要回滚,您需要发布具有更高版本号的先前二进制文件...
    【解决方案2】:

    您可以使用 Mage.exe 将您的部署清单(.application 文件扩展名)更新到更高版本,并选择之前版本的应用程序清单。就像chilltemp 说的,你仍然需要去更高版本,但你不必重新部署你的代码。

    【讨论】:

    • 您必须复制要回滚_v_{0}_{1}_{2}_{3}文件夹并命名它的版本 # 比您要摆脱的版本高,然后使用 MageUI(或 Mage,但在本例中为 MageUI)首先指向 ClickOnce 根目录中的 .application 文件 ,更改版本号,让它指向新文件夹中的 .manifest 文件,然后保存。对我来说,我还必须签署申请。 “降级”确实有效,但它没有读取我之前的应用设置,导致此方法对我无法使用。 (不确定我是不是做错了什么,但那是一个破坏者。)
    【解决方案3】:

    如果您想将版本回滚到客户端最低要求版本之前的上一个版本,那么您需要重新安装 clickonce 应用程序。

    看看这个链接,看看它是如何在代码中完成的:ClickOnce and Expiring Code Signing Certificates

    【讨论】:

      【解决方案4】:

      如果您知道发布者 uri 以及部署和应用程序的名称、版本语言公钥令牌和处理器架构,这可以通过反射来完成。

      下面的代码将尝试回滚“coolapp.app”点击一次应用。如果无法回滚,它会尝试卸载它。

      
      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 });
                  }
              }
          }
      }
      

      【讨论】:

        猜你喜欢
        • 2017-01-07
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-01-22
        • 2013-04-05
        • 2018-12-30
        相关资源
        最近更新 更多