ClickOnce - automatically making all builds required?

╄→гoц情女王★ 提交于 2019-12-24 17:08:57

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!