问题
We have an app which I've coded up and for ages now I've pushed updates to it through ClickOnce. The app sits on our main file server. But every time I push out an update I get asked what I've changed! Is there any way to provide a personalised description of an update with ClickOnce which would be user-friendly? For example, when the user launches their application, ClickOnce asks "A new version is available. Would you like to update?", below which I could have a description of what I've updated? Or is this impossible with ClickOnce?
回答1:
Here's how I do it. I call this method in my startup code, in Release mode:
using System.Deployment.Application;
...
private void DisplayChangeLog()
{
if (!ApplicationDeployment.IsNetworkDeployed)
return;
if (!ApplicationDeployment.CurrentDeployment.IsFirstRun)
return;
ThreadPool.QueueUserWorkItem(state =>
Execute.OnUIThread(() => <Pop up window with latest changes> ));
}
I know this isn't precisely what you want, as it displays the first time the user runs the app but after they've already installed the update. In our environment users don't have a choice whether they update or not, so it makes no real difference.
回答2:
It is not possible to do with ClickOnce as standard. If you want to show the user a message about changes then you will need to implement it yourself. One way to do this is to diable automatic updating and then check for updates programatically. You can then use the version to get the change from say an XML file or similar and show it to the user.
Alternatively, you could just provide a changelog in HTML format or something which is likely a lot simpler.
For example, see Stack Overflow question Looking for recomendation to show release notes in ClickOnce applications.
Either way, in general if there is an update, why would the user not want it?
回答3:
I have spent a considerable amount of time in the recent past studying and programmatically manipulating the manifest files that are produced during the publishing of a ClickOnce application and I've not seen a way to add a free form description like the one you want, and there certainly isn't a way to achieve it via the wizard or UI provided by Visual Studio.
(Caveat: I'll double check this tomorrow at work just to make sure there is absolutely no way at all - but you should assume that there isn't.)
回答4:
There is no way to change the update dialog for ClickOnce as long as you let ClickOnce check for updates automatically.
To achieve this, you would have to handle updates programmatically in your application using the methods provided by ApplicationDeployment.CurrentDeployment
. This allows you to define your own update dialog. See here for the official HowTo. The core principle is the following:
ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;
info = ad.CheckForDetailedUpdate();
if (info.UpdateAvailable)
{
// insert your update dialog here
ad.Update();
}
However, there used to be a bug within the approach described in there when calling ad.Update()
and you have file associations in your ClickOnce deployment. See the forum and bug report for more info. (I don't know if the bug has been fixed.)
As a workaround for this, you could replace ad.Update()
by these lines:
var application = ApplicationDeployment.CurrentDeployment.UpdatedApplicationFullName.Split('#')[0] + "?";
proc = new Process { StartInfo = { FileName = "iexplore.exe", Arguments = application, UseShellExecute = true } };
proc.Start();
Application.Current.Shutdown();
来源:https://stackoverflow.com/questions/17343101/how-to-provide-description-of-update-with-clickonce