Is it safe to use autogenerated GUID on Component

2019-02-03 00:01发布

问题:

My scenario is this: I want the installer to completely remove the old version (all files except those created by the application during its lifetime) and replace it with the new version.

In my Wix script I use auto-generated GUID (asterisk) for Product ID and Package ID, while I use my own GUID for UpgradeCode which always stays same. What I'm not sure if I can safely use auto-generated GUID (asterisk) for Component tags as well, with respect to my scenario?

So far I was using NSIS. I wanted to try Wix but got a little doubt since people on forums say it will take you about 30 days to learn it while one can start off with NSIS in 1-2 days. However, for a standard installation that typical users need, it took me 2 days to get a really good installer package using Wix. If you have a little background in xml you should probably have no worries. Thanks to Rob and all the other contributors for creating the Wix!

回答1:

Yes, the auto-guid Component/@Guid are safe. They are done very specially to ensure that the GUID is generated in a way that is stable across releases for that Component such that the Component Rules are not violated.

Additionally, if you do not share Components with other Products and you always use major upgrades and you schedule the major upgrade early, then you don't have to worry about Component GUIDs much at all, because the two Component GUID definitions will never be on the machine at the same time. For example, the defaults for the MajorUpgrade element give you exactly this:

<MajorUpgrade DowngradeErrorMessage='A newer version of [ProductName] is installed.' />

So, the answer is, "Yes". :)