【问题标题】:Uninstalling a previous component before installing a new one using VS 2005 Setup Project在使用 VS 2005 安装项目安装新组件之前卸载以前的组件
【发布时间】:2011-05-11 16:22:15
【问题描述】:

我有一个应该在 .msi 设置的安装部分执行的自定义操作。我有一个使用 InstallShield 安装的以前的版本(这有点过头了),我想转移到更简单的 VS Setup Proj,因为我不需要 .isproj 提供的所有控制。但是,使用我的新 .msi 直接安装似乎与以前的版本并排安装。以下是我目前发现的:

  1. 我有我的产品 ID
  2. 我已经编写了代码,通过创建一个使用 MsiExec.exe 的进程来卸载以前的版本(代码如下)
  3. 尝试在安装过程中实施自定义操作以卸载,但您似乎一次只能运行一个 MsiExec.exe 实例。
  4. 去过这篇文章 (http://stackoverflow.com/questions/197365/vs-setup-project-uninstall-other-component-on-install),但没有帮助。

自定义操作代码:

        //Exe used to uninstall
        string fileName = "MsiExec.exe";

        //Product ID of versions installed using InstallShield
        string productID = "{DC625BCF-5E7B-4FEF-96DD-3CDBA7FC02C1}";

        //Use /x for uninstall and use /qn to supress interface
        ProcessStartInfo startInfo = new ProcessStartInfo(fileName, string.Format("/x{0}", productID));
        startInfo.WindowStyle = ProcessWindowStyle.Normal;
        startInfo.UseShellExecute = false;

        //Start process
        Process uninstallProcess = Process.Start(startInfo);

        //Wait until uninstall is complete
        uninstallProcess.WaitForExit();

我希望最终通过 ClickOnce 部署我的 .msi,所以我希望有一个适合部署选项的选项。目前一切都是用 .NET 2.0 和 VS 2005 编写的,但如果有新的选项可以使用,我确实可以使用 .NET 4.0 和 VS 2010。

感谢任何帮助。

【问题讨论】:

    标签: c# visual-studio-2005 setup-project uninstallation custom-action


    【解决方案1】:

    通过使我的设置的产品代码与旧版本的代码相同,我能够在先前安装的基础上进行安装。没想到我会尝试这样做,因为当您创建新版本的安装包时,VS 总是提示您更改产品代码。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多