C# 自动更新应用程序.net/wpf

C# 自动更新应用程序.net/wpf,c#,.net,wpf,auto-update,C#,.net,Wpf,Auto Update,我寻求通过互联网更新我在“C#/.NET/WPF”中开发的程序的解决方案。 此项目包含具有不同文件类型的子目录以及不同的库(dll) 到目前为止,我在一个.zip文件中分发了我的程序,其中包含所有文件(总共800kb),作为一个可移植的解决方案 我并不特别需要安装,但我寻求一个免费的升级解决方案 我尝试了ClickOnce,但无法以“便携方式”分发应用程序,并且应用程序的安装位置不适合我 我看了WiX,但有一个功能通知,并通过互联网进行更新 其他解决方案 我在msdn上找到了类似的内容: pr

我寻求通过互联网更新我在“C#/.NET/WPF”中开发的程序的解决方案。 此项目包含具有不同文件类型的子目录以及不同的库(dll)

到目前为止,我在一个.zip文件中分发了我的程序,其中包含所有文件(总共800kb),作为一个可移植的解决方案

我并不特别需要安装,但我寻求一个免费的升级解决方案

  • 我尝试了ClickOnce,但无法以“便携方式”分发应用程序,并且应用程序的安装位置不适合我

  • 我看了WiX,但有一个功能通知,并通过互联网进行更新

  • 其他解决方案


我在msdn上找到了类似的内容:

private void InstallUpdateSyncWithInfo()
{
    UpdateCheckInfo info = null;

    if (ApplicationDeployment.IsNetworkDeployed)
    {
        ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;

        try
        {
            info = ad.CheckForDetailedUpdate();

        }
        catch (DeploymentDownloadException dde)
        {
            MessageBox.Show("The new version of the application cannot be downloaded at this time. \n\nPlease check your network connection, or try again later. Error: " + dde.Message);
            return;
        }
        catch (InvalidDeploymentException ide)
        {
            MessageBox.Show("Cannot check for a new version of the application. The ClickOnce deployment is corrupt. Please redeploy the application and try again. Error: " + ide.Message);
            return;
        }
        catch (InvalidOperationException ioe)
        {
            MessageBox.Show("This application cannot be updated. It is likely not a ClickOnce application. Error: " + ioe.Message);
            return;
        }

        if (info.UpdateAvailable)
        {
            Boolean doUpdate = true;

            if (!info.IsUpdateRequired)
            {
                DialogResult dr = MessageBox.Show("An update is available. Would you like to update the application now?", "Update Available", MessageBoxButtons.OKCancel);
                if (!(DialogResult.OK == dr))
                {
                    doUpdate = false;
                }
            }
            else
            {
                // Display a message that the app MUST reboot. Display the minimum required version.
                MessageBox.Show("This application has detected a mandatory update from your current " + 
                    "version to version " + info.MinimumRequiredVersion.ToString() + 
                    ". The application will now install the update and restart.", 
                    "Update Available", MessageBoxButtons.OK, 
                    MessageBoxIcon.Information);
            }

            if (doUpdate)
            {
                try
                {
                    ad.Update();
                    MessageBox.Show("The application has been upgraded, and will now restart.");
                    Application.Restart();
                }
                catch (DeploymentDownloadException dde)
                {
                    MessageBox.Show("Cannot install the latest version of the application. \n\nPlease check your network connection, or try again later. Error: " + dde);
                    return;
                }
            }
        }
    }
}

要指定备用更新源,可以使用MageUI

1.打开.NET Framework命令提示符并键入: mageui.exe

2.在“文件”菜单上,选择“打开”以打开应用程序的部署清单

3.选择部署选项选项卡

4.在名为Launch Location的文本框中,输入将包含应用程序更新的部署清单的目录的URL


5.保存部署清单。

我已经看到这一点,但我无法将我的应用程序分发到“可移植”版本,只想使用clickOnce更新系统!总有一个设置,我不想。我想分发到.zip。我想将我的应用程序分发到“portable”+AutoUpdate。我将自己进行更新,这不是很复杂。