Visual Studio 2010-RemovePreviousVersions [英] Visual Studio 2010 - RemovePreviousVersions

查看:88
本文介绍了Visual Studio 2010-RemovePreviousVersions的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有以下设置的Visual Studio 2010部署项目:

I have a Visual Studio 2010 Deployment Project with the following settings:

DetectNewerInstalledVersion = True
InstallAllUsers = True
RemovePreviousVersions = True

我正在构建的项目具有多个DLL,由于实现序列化的传统方式,该项目的文件版本无法递增(我们正在更改中).

The project I am building has several DLLs that due to the legacy way that serialization was implemented the file versions for this project can not be incremented (which we are in the process of changing).

如何获得安装项目以完全删除现有文件(或至少覆盖所有新文件)?

How can I get the setup project to remove the existing files entirely (or at least overwrite with all the new files)?

也许我需要在安装程序中编写一个卸载脚本(有人可以链接我来执行此操作,我找不到)

Maybe I need to script an uninstall in the installer (can someone link me to do this, I can't find)

我环顾四周,查找任何现有问题,他们都说增加文件版本",但是对我来说这不是一个选择.

I have looked around and for any existing questions and they all say "increment your file versions", however for me this is not currently an option.

推荐答案

使用Visual Studio创建的安装项目(2008和2010)将仅在版本号增加的情况下替换文件.显而易见的解决方案是仅增加所有版本号.但是正如您所说,这对您来说是不可行的.

The setup project created with Visual Studio (2008 and 2010) will only replace files if the version number has been incremented. The obvious solution would be to just increment all version numbers; but as you said this is not feasible for you.

.msi文件的行为基本上由 RemoveExistingProducts 动作发生的那一刻确定.被执行.使用VS 2008创建的安装程序会在安装新产品后 安排此操作.版本未增加的已修改程序集因此不会被替换.此线程中描述了有关更新行为的更多详细信息:

The behavior of the .msi file is basically determined by the moment when the RemoveExistingProducts action is executed. Installers created with VS 2008 schedule this action after the new product has been installed. Modified assemblies whose version has not been incremented therefore don't get replaced. Some more details about the update behavior are described in this thread:

RemovePreviousVersions = True,但是未删除以前的版本从目标计算机上

要更改行为,可以修补创建的.msi文件,以便 RemoveExistingProducts 在安装新产品之前,在之前执行操作(实际上是使用Visual Studio 2005创建安装程序时的行为).修补可以例如可以使用一个小型的VBScript来完成,该VBScript可以作为后建步骤运行:

To change the behavior, you can patch the created .msi file so that the RemoveExistingProducts action is executed before the new product gets installed (this actually has been the behavior if you created the setup with Visual Studio 2005). Patching can e.g. be done using a small VBScript that runs as a post-built step:

Dim objInstaller
Dim objDatabase
Dim objView
Dim objResult

Dim strPathMsi 

If WScript.Arguments.Count <> 1 Then
    WScript.Echo "Usage: cscript fixRemovePreviousVersions.vbs <path to MSI>"
    WScript.Quit -1
End If

strPathMsi = WScript.Arguments(0)

Set objInstaller = CreateObject("WindowsInstaller.Installer")
Set objDatabase = objInstaller.OpenDatabase(strPathMsi, 1)
Set objView = objDatabase.OpenView("UPDATE InstallExecuteSequence SET Sequence=1450 WHERE Action='RemoveExistingProducts'")

WScript.Echo "Patching install sequence: UPDATE InstallExecuteSequence SET Sequence=1450 WHERE Action='RemoveExistingProducts'"
objView.Execute
objDatabase.Commit

WScript.Quit 0

这篇关于Visual Studio 2010-RemovePreviousVersions的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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