[英]How to detect an update using .NET 2 System.Configuration.Install?
I created a class derived from System.Configuration.Install for my installer. 我为我的安装程序创建了一个派生自System.Configuration.Install的类。
But the code in Uninstall() is being called when I try to update the application. 但是当我尝试更新应用程序时,正在调用Uninstall()中的代码。
How can I detect that the user is trying to update instead of uninstall? 如何检测用户是否尝试更新而不是卸载?
Maybe this post explains it better than me: 也许这篇文章比我解释得更好:
My problem boils down to: when the user performs an update (ie double clicks on MyAppVer2.msi when they already have MyAppVer1.msi installed) the Uninstall method inside my Installer is called first, but I have no apparent property to check from inside this method to detect that an update is being performed so that I can branch my code appropriately. 我的问题归结为:当用户执行更新时(即,当他们已经安装了MyAppVer1.msi时双击MyAppVer2.msi)首先调用我的安装程序中的Uninstall方法,但我没有明显的属性可以从内部检查检测正在执行更新的方法,以便我可以适当地分支我的代码。
您的安装项目中有一个设置默认情况下会“卸载”以前的版本,关闭此标志,那么您不必担心!
Blind guess here, but I'd start out by checking the Installer.Context property for a parameter . 盲目猜测,但我首先检查一下参数的Installer.Context属性。 If that's no help, there may be something in the savedState parameter passed to Uninstall . 如果没有帮助,saveState参数中可能会有一些内容传递给Uninstall 。
Last chance would be to prompt the user , and set the child installers as appropiate. 最后一次机会是提示用户 ,并将子安装程序设置为适当的。
The deployment project that ships with Visual Studio is SEVERELY underpowered to deal with anything beyond the simpiliest scenarios. Visual Studio附带的部署项目严重不足以处理除最简单场景之外的任何事情。
In your case, you'll need to do one of the following: 在您的情况下,您需要执行以下操作之一:
有没有理由你不能使用WIX,它可以更有效地处理这类事情,看看升级教程, 在这里
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.