使用 VS 2005 安装项目安装新组件之前卸载以前的组件

发布于 2024-10-03 17:44:07 字数 1257 浏览 1 评论 0原文

我有一个自定义操作,应在 .msi 设置的安装部分执行。我有一个使用 InstallShield 安装的先前版本(这有点过头了),并且想要移动到更简单的 VS 安装项目,因为我不需要 .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。

任何帮助表示赞赏。

I have a Custom Action that should execute during the Install portion of an .msi setup. I have a previous version that was installed using InstallShield (which was overkill) and wanted to move to the simpler VS Setup Proj because I do not require all the control that an .isproj provides. However, doing a straight install with my new .msi seems to install side by side with the previous version. Here's what I have found out so far:

  1. I have my product ID
  2. I have written code that will uninstall the previous version through creating a process that uses MsiExec.exe (code will follow)
  3. Tried implementing the custom action to uninstall during setup but it seems you can only have one instance of MsiExec.exe running at a time.
  4. Have been to this post (http://stackoverflow.com/questions/197365/vs-setup-project-uninstall-other-component-on-install), which didnt help.

Custom Action code:

        //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();

My hope is to eventually deploy my .msi via ClickOnce, so I am hoping for an option that will fit into deployment option. Currently everything is written in .NET 2.0 and VS 2005, but I do have .NET 4.0 and VS 2010 available to me if there is a new option that works.

Any help is appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦言归人 2024-10-10 17:44:07

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

I was able to install over the top of the previous install by making the product code of my setup the same as the code of the older version. Didn't dawn on me to try that because when you create a new version of the setup package, VS always prompts you to change your product code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文