code检查更新,安装应用程序的新版本 [英] Code to check for updates, install new version of app

查看:143
本文介绍了code检查更新,安装应用程序的新版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个.NET 4的WPF应用程序,使用MSI被安装,通过一个Visual Studio安装项目产生的。一切都很正常,但我错过了一次单击部署功能来检查负载和下载应用程序的新版本/安装它们。我切离点击一次部署,因为它似乎是一个不成熟的解决方案,让你做黑客只是不喜欢有启动您的应用程序运行简单的事情。

我想知道是否有任何形式的教程或code任何人都可以告诉我,勾画出如何处理检查应用程序的新版本,下载应用程序的新版本,在安装新的应用程序旧的。这似乎是一些大多数WPF应用程序都希望拥有的,我很惊讶,我找不到这个对谷歌任何东西。

解决方案

有没有这样的内置或现成的工具。在应用程序启动时,你可以运行你的code这不下面。

  1. 获取您的 http://myserver.com/myproduct/update.xml ,在那里你会保持设置你的新的更新msi文件的最新版本,网址
  2. 如果有可用更新,不同的是那么当前运行的版本,然后使用Web客户端下载文件并将其保存在临时文件夹
  3. 您可以再创建以下字符串一个批处理文件并将其保存在临时文件夹

  MSIEXEC / U {产品code}
MSIEXEC /我..path到新的MSI
 

最后使用的Process.Start执行批处理文件并退出应用程序。

I have a .NET 4 WPF app that gets installed using an MSI, generated via a visual studio setup project. Everything works great, except that I'm missing the Click Once Deployment feature that checks for new versions of the app on load and downloads/installs them. I switched away from Click Once Deployment because it seems to be a half-baked solution that makes you do hacks just to do simple things like have your app run on startup.

I was wondering if there is any sort of tutorial or code anyone can show me that lays out how to handle checking for new versions of the app, downloading the new version of the app, and installing the new app over the old one. This seems like something that most WPF apps would want to have, I'm surprised that I can't find anything about this on google.

解决方案

There is no such inbuilt or ready made tool. In startup of your application you can run your code which does following.

  1. Fetch your http://myserver.com/myproduct/update.xml, where you will keep settings of your latest version and url of a new update msi file
  2. If update is available that is different then the currently running version, then download the file using WebClient and store it in temp folder
  3. You can then create a batch file with following string and store it in temp folder

msiexec /u {your product code}
msiexec /i ..path to your new msi

Finally Execute your batch file using Process.Start and exit your app.

这篇关于code检查更新,安装应用程序的新版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆