Gro*_*mer 10
看起来你可以通过改变构建中的一些属性来做到这一点.
http://blog.jnericks.com/configuring-msbuild-to-auto-update-clickonce
- MinimumRequiredVersion - 告诉ClickOnce,当它更新此应用程序时,它应该更新到此版本(但是这不会强制ClickOnce执行更新).如您所见,我们将其设置为ApplicationVersion设置的相同版本号,以便MinimumRequiredVersion始终是最新版本.
- UpdateMode = Foreground - 告诉ClickOnce在打开应用程序之前更新它.
- UpdateRequired = True - 告诉ClickOnce自动执行更新.
没有MSBuild场景:
然后发布应用程序并测试它.在本地测试应用程序中,这对我来说很好.
编辑:看起来有些人已经获得了更新所需的最低版本,可能想要查看他们的解决方案.
编辑2:显示版本控制重要性的图像:
另外,请注意我已选中"每次发布时自动增加修订".每次进入项目的属性时,该版本都是最新的.您通常只需在"应用程序更新"窗口中更改版本的"修订版"部分,以匹配"发布"选项卡中的"修订版".
当然可以!只要它是网络部署的应用程序,您就可以使用此代码轻松检查更新。见下文:
Private Sub InstallUpdates()
Dim info As UpdateCheckInfo = Nothing
If (ApplicationDeployment.IsNetworkDeployed) Then
Dim AD As ApplicationDeployment = ApplicationDeployment.CurrentDeployment
Try
info = AD.CheckForDetailedUpdate()
Catch dde As DeploymentDownloadException
(You may want to log here)
Return
Catch ioe As InvalidOperationException
(You may want to log here)
Return
End Try
If (info.UpdateAvailable) Then
Try
AD.Update()
Application.Restart()
Catch dde As DeploymentDownloadException
(You may want to log here)
Return
End Try
End If
End If
End Sub
Run Code Online (Sandbox Code Playgroud)
您可以输入此代码段并在启动时调用它。它适用于控制台应用程序、Windows 窗体应用程序,但前提是您已部署网络!你看到我所有关于日志记录的评论是我最初使用带有提示的消息框的地方,但这是不需要任何输入的版本!