visual-studio VS2008 安装项目:卸载以前的 MSI

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2072856/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 11:24:56  来源:igfitidea点击:

VS2008 Setup Project: Uninstalling the previous MSI

c#visual-studiowinformswindows-installerinstallation

提问by Matt Bishop

I have a VS2008 setup project, which creates a setup.msi which installs a WinForms application (C#).

我有一个 VS2008 安装项目,它创建了一个安装 WinForms 应用程序 (C#) 的 setup.msi。

Every time I update the version number, the users first have to uninstall the previous version before they can install the new one. Otherwise we get the dreaded "Another version of this product is already installed" message.

每次更新版本号时,用户都必须先卸载以前的版本,然后才能安装新版本。否则,我们会收到可怕的“此产品的另一个版本已安装”消息。

This is what I'm doing already when I build a new version of the installer:

当我构建新版本的安装程序时,这就是我已经在做的事情:

  • Set RemovePreviousVersions=true and DetectNewerInstalledVersion=true
  • Increment AssemblyVersion(of the exe that's being deployed)
  • Increment Version(of the setup project)
  • Generate a new ProductCode(as prompted by VS, when the Version is changed)
  • Leave UpgradeCodeunchanged
  • 设置RemovePreviousVersions=true 和DetectNewerInstalledVersion=true
  • 增加AssemblyVersion(正在部署的 exe)
  • 增量版本(安装项目的)
  • 生成新的ProductCode(根据VS提示,当Version改变时)
  • 保持升级代码不变

And yet it still refuses to uninstall the previous version. So, what have I missed? Or what am I doing wrong?

但它仍然拒绝卸载以前的版本。那么,我错过了什么?或者我做错了什么?

Thanks!

谢谢!

回答by Matt Bishop

Semi-answering my own question, just for the benefit of anyone who's interested:

半回答我自己的问题,只是为了任何感兴趣的人的利益:

Firstly, I found an incredibly useful articleon how MSI updates work.

首先,我发现了一篇关于 MSI 更新如何工作的非常有用的文章

Secondly, I found InstEd, a rather nice freeware MSI editor, which showed me that there was nothing obviously wrong with my MSI file. (Yes, I could use Orca instead, if I didn't mind downloading the whole Windows SDK to get it.)

其次,我找到了InstEd,一个相当不错的免费软件 MSI 编辑器,它告诉我我的 MSI 文件没有任何明显的错误。(是的,如果我不介意下载整个 Windows SDK 来获取它,我可以改用 Orca。)

Thirdly, and annoyingly, the original problem seems to have fixed itself and I can't reproduce it any more. If it comes back, and if I fix it again, I'll add a comment here!

第三,令人讨厌的是,原来的问题似乎已经解决了,我不能再重现它了。如果它回来了,如果我再次修复它,我会在这里添加评论!

Anyway, all this brought up a new - arguably worse - problem: the MSI now claimedto update the application but didn't actually install anything! The solution to that is as follows:

无论如何,所有这些都带来了一个新的——可以说是更糟的——问题:MSI 现在声称更新了应用程序,但实际上并没有安装任何东西!解决方法如下:

  • AssemblyVersion doesn't matter, but AssemblyFileVersion absolutely does: it mustincrement, if you want the new files to be installed. (This is a change in VS2008, compared to VS2005. See, for instance, this discussionon the Microsoft groups.)
  • However, AssemblyFileVersion can't autoincrement the way AssemblyVersion can. Setting it to 1.9.* (or whatever) will just result in an error. The solution, from Stack Overflowthis time, is to set AssemblyVersion to autoincrement, and then open AssemblyInfo.cs and remove the AssemblyFileVersion attribute altogether. This will force the file version to equal the assembly version.
  • 的AssemblyVersion无所谓,但绝对的AssemblyFileVersion :它必须增加,如果要安装新的文件。(与 VS2005 相比,这是 VS2008 中的一个变化。例如,参见Microsoft 组的讨论。)
  • 但是,AssemblyFileVersion 不能像 AssemblyVersion 那样自动递增。将其设置为 1.9.* (或其他)只会导致错误。这次Stack Overflow的解决方案是将AssemblyVersion设置为自动递增,然后打开AssemblyInfo.cs并完全删除AssemblyFileVersion属性。这将强制文件版本等于程序集版本。

回答by JBrooks

To have it install over the previous version:

要在以前的版本上安装它:

  1. Highlight the setup project.
  2. Press the F4 key for properties. (Right Click is a different properties box.)
  3. Change Version. Say yes to the prompt asking to change the product code.
  1. 突出显示安装项目。
  2. 按 F4 键查看属性。(右键单击是一个不同的属性框。)
  3. 更改版本。对要求更改产品代码的提示说“是”。

Keep in mind, even if you rebuild the solution it doesn't rebuild the setup project. You need to rebuild the setup project as a separate step.

请记住,即使您重建解决方案,它也不会重建安装项目。您需要作为单独的步骤重建安装项目。

Second, you don't need to Increment AssemblyVersion every time. Set it to something like 2.1.* and it will do it automatically.

其次,您不需要每次都增加 AssemblyVersion。将其设置为 2.1.* 之类的内容,它会自动执行。

回答by Fred

I am not 100% familiar with VS 2008 setup projects (I use Advanced Installermyself- HIGHLY recommend it BTW; they even have a freeware version!), but I have run into this before and it's not documented very clearly.

我不是 100% 熟悉 VS 2008 安装项目(我自己使用高级安装程序 -顺便强烈推荐它;他们甚至有免费软件版本!),但我之前遇到过这个问题,并且没有很清楚地记录下来。

There are 4 parts to the version number- as you are well aware I'm sure: Major.Minor.Build.Revision. The REVISION is NOT checked by windows installer. If all you're doing is incrementing the revision, it won't work. You have to increment at least the build of the ProductVersion value.

版本号有 4 个部分——你很清楚,我敢肯定:Major.Minor.Build.Revision。Windows 安装程序不会检查 REVISION。如果您所做的只是增加修订版,则它将不起作用。您必须至少增加 ProductVersion 值的构建。

Hope that helps!

希望有帮助!

回答by Ed.

The Installer service is making decisions based on the contents of the Upgrade Table, so that's where I would look. Does the table have an entry for your upgrade code, does the product version of the currently installed version fall within the range of versions specified for upgrades, do the attributes look ok (for instance, is the msidbUpgradeAttributesOnlyDetectattribute not set), and so on.

安装程序服务根据升级表的内容做出决定,所以这就是我要查看的地方。该表是否有您的升级代码条目,当前安装版本的产品版本是否在升级指定的版本范围内,属性是否正常(例如,msidbUpgradeAttributesOnlyDetect属性是否未设置)等等。

MSDN describes it all here - http://msdn.microsoft.com/en-us/library/aa372379%28VS.85%29.aspx

MSDN 在这里描述了这一切 - http://msdn.microsoft.com/en-us/library/aa372379%28VS.85%29.aspx

回答by Aman

Don't forget to increment the assemblyFileVersion! If you don't specify the assembly file version then the compiler assumes it to be the same as assemblyVersion. However, if assemblyFileVersion is specified then it must be incremented.

不要忘记增加 assemblyFileVersion!如果未指定程序集文件版本,则编译器假定它与 assemblyVersion 相同。但是,如果指定了 assemblyFileVersion,则它必须递增。

回答by Repeat Spacer

I came here to get help to same problem. After reading linked incredible useful articleI suppose my problem was, that I had installed previous version with "Just me" option and the new installer had InstallAllUsers property selected (in Visual Studio project properties). So after uninstalling previous installation from control panel the update now works. Maybe this helps someone.

我来这里是为了解决同样的问题。在阅读了链接的令人难以置信的有用文章后,我想我的问题是,我安装了带有“Just me”选项的先前版本,并且新安装程序选择了 InstallAllUsers 属性(在 Visual Studio 项目属性中)。因此,从控制面板卸载以前的安装后,更新现在可以工作了。也许这对某人有帮助。