首页 > 代码库 > C# ClickOnce发布方式

C# ClickOnce发布方式

首先编写ClickOnce更新事件,

 1   private void button1_Click(object sender, EventArgs e)
 2         {
 3             if (ApplicationDeployment.IsNetworkDeployed)
 4             {
 5                 ApplicationDeployment.CurrentDeployment.CheckForUpdateCompleted +=
 6                   (sender1, e1) =>
 7                   {
 8                       if (e1.UpdateAvailable)
 9                       {
10                           ApplicationDeployment.CurrentDeployment.UpdateCompleted +=
11                     (sender2, e2) =>
12                         {
13                             MessageBox.Show("Update completed");
14                         };
15                           ApplicationDeployment.CurrentDeployment.UpdateAsync();
16                       }
17                       else
18                       {
19                           MessageBox.Show("No update available");
20                       }
21 
22                   };
23                 ApplicationDeployment.CurrentDeployment.CheckForUpdateAsync();
24             }
25         }

 配置项目发布

技术分享

 

浏览发布地址进行安装 http://192.168.31.180:79/publish.htm 进行安装

技术分享

 

点击update 更新,如果服务器上有版本更新, 就可下载文件覆盖

 

C# ClickOnce发布方式