MSI/WiX – 在构建之间是否应更改ProductCode?

huangapple go评论58阅读模式
英文:

MSI/WiX - Should ProductCode change between builds?

问题

我正在使用WiX来创建我的项目的安装程序,但我对ProductCode的作用有点困惑。

在WiX中,似乎首选的行为是不手动设置ProductCode,只是让它在每次重新构建MSI以进行新版本发布时生成一个新的GUID,而不考虑发生了什么变化。实际上,Visual Studio中的默认WiX项目指定了一个UpgradeCode,但没有指定一个ProductCode。

这样做没有问题,但我认为ProductCode应该用作Windows中应用程序的主要标识符,不论版本或构建如何,所以它不应该在每次更新发布时重新生成,对吗?

另外,如果我想从注册表中读取有关应用程序的信息,比如其名称、版本或卸载字符串,我必须在Microsoft\Windows\CurrentVersion\Uninstall下搜索其ProductCode - 所以看起来代码应该是一致的,对吗?或者也许有更好的方法来从注册表中查找有关程序的信息。

那么哪种解释是正确的 - 应该是固定的还是在构建之间更改的?

英文:

I'm using WiX to create an installer for my project, and I'm a bit confused about what ProductCode should do.

It seems that the preferred behaviour in WiX is to not set the ProductCode manually, and just let it generate a new GUID every time I rebuild the MSI for a new release, regardless of what has changed. In fact, the default WiX project in visual studio specifies an UpgradeCode but it doesn't specify a ProductCode.

This works fine, but I thought that a ProductCode was used as the main identifier for an application in Windows regardless of version or build, and so surely it shouldn't regenerate every time an update is shipped?

Also if I want to read info about an application from the registry such as its name, version or uninstall string, I have to search for its ProductCode under Microsoft\Windows\CurrentVersion\Uninstall - so it seems that the code should be consistent, right? Or maybe there's a better way to look up info about a program from the registry.

So which interpretation is right - should it be fixed or change between builds?

答案1

得分: 1

  • 当您希望手动指定产品代码时,可以考虑以下情况:

  • 您拥有其他产品,该产品通过注册表中的代码查找您的产品。例如,要检查是否已安装。 Windows Installer API可用于通过产品代码查找已安装的产品。此外,标准的MSI操作“FindRelatedProducts”也使用产品代码。当您希望卸载的不是您的产品,而是其他人的产品时,这可能会有用。

  • 当您使用与默认的“主要更新”不同的更新模式时,先完全卸载先前的产品,然后安装新版本(例如,您使用类似“补丁”或“次要更新”的东西,仅更新产品的某些组件时)。请注意,大多数产品不使用此特殊模式。

总之,所有这些情况都是边缘情况,我建议依赖默认行为,除非您知道自己在做什么以及为什么要这样做。这种默认行为是合适的。

请注意,对于主要更新(这是最常见的更新类型),必须更改产品代码,而此行为确保了这一点。

英文:

I can think of the following scenarios when you want your product code to be fixed (specified manually):

  • You have some other product that is looking for your product one by code in the registry. To check if it is installed, for example. There is a Windows Installer API available to look for an installed product by product code. Also, the standard MSI action "FindRelatedProducts" uses product codes. This may be useful when you want to uninstall not your product but somebody else's other product on your product installation.

  • You use an update mode different from the default "major update" when a previous product is completely uninstalled and then a new version is installed (i.e. you use something like "patches" or "minor updates", when only some components of the product are updated). Please note that most of the products don't use this special mode.

Anyway, all these scenarios are marginal, I would rely on the default behavior unless you know what you are doing and why. This default behavior is fine.

Please note that product code MUST be changed for major updates (which is the most common type of update), and this behavior ensures it is.

huangapple
  • 本文由 发表于 2023年7月17日 16:44:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/76702783.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定