问题
Is there a script for always making all my published builds required, update-wise? I want to force an update to all my customers no matter what, however, they are asked whether or not they want to update, even after using the ClickOnce deployment API.
回答1:
Yes, you can force an upgrade for all customers by requiring a minimal version. This is so that you can make incompatible server changes.
From MSDN:
To mark an update as required, click Specify a minimum required version for this application in the Application Updates dialog box, then specify the publish version (Major, Minor, Build, Revision), which specifies the lowest version number of the application that can be installed.
回答2:
I ended up using the ClickOnce deployment API, where I have much more control over the process. The trick is to set the application as a CD-ROM application that runs 100% offline. Then, using simple ClickOnce code, a silent update can be performed.
private void Update()
{
try
{
ApplicationDeployment.CurrentDeployment.CheckForUpdateCompleted += new CheckForUpdateCompletedEventHandler(CurrentDeployment_CheckForUpdateCompleted);
ApplicationDeployment.CurrentDeployment.UpdateCompleted += new System.ComponentModel.AsyncCompletedEventHandler(CurrentDeployment_UpdateCompleted);
ApplicationDeployment.CurrentDeployment.CheckForUpdateAsync();
}
catch (Exception)
{
}
}
void CurrentDeployment_CheckForUpdateCompleted(object sender, CheckForUpdateCompletedEventArgs e)
{
try
{
if (e.UpdateAvailable)
{
ApplicationDeployment.CurrentDeployment.UpdateAsync();
}
}
catch (InvalidOperationException)
{
}
}
void CurrentDeployment_UpdateCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
{
//TODO: update completion code here
}
来源:https://stackoverflow.com/questions/7184141/clickonce-automatically-making-all-builds-required