【发布时间】:2012-07-01 21:22:35
【问题描述】:
我们决定在 clickOnce 应用程序清单中使用 minimumRequiredVersion,现在当用户启动应用程序时我们尝试回滚到以前的版本时,它无法启动。它说应用程序清单的版本早于所需版本,用户无法使用该应用程序。如果没有 minimumRequiredVersion,我们没有这个问题,但我们想使用它。
【问题讨论】:
我们决定在 clickOnce 应用程序清单中使用 minimumRequiredVersion,现在当用户启动应用程序时我们尝试回滚到以前的版本时,它无法启动。它说应用程序清单的版本早于所需版本,用户无法使用该应用程序。如果没有 minimumRequiredVersion,我们没有这个问题,但我们想使用它。
【问题讨论】:
您必须部署具有更高版本号的新版本。没有内置的回滚功能。
【讨论】:
您可以使用 Mage.exe 将您的部署清单(.application 文件扩展名)更新到更高版本,并选择之前版本的应用程序清单。就像chilltemp 说的,你仍然需要去更高版本,但你不必重新部署你的代码。
【讨论】:
如果您想将版本回滚到客户端最低要求版本之前的上一个版本,那么您需要重新安装 clickonce 应用程序。
看看这个链接,看看它是如何在代码中完成的:ClickOnce and Expiring Code Signing Certificates
【讨论】:
如果您知道发布者 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 });
}
}
}
}
【讨论】: