Doing a small update or minor upgrade in MSI? Use MSIENFORCEUPGRADECOMPONENTRULES.

This little tip for those of you trying to do a small update or minor upgrade has been sitting in my "to blog" box for a long while. If you are developing a small update or minor upgrade for your MSI product, I encourage you to set the MSIENFORCEUPGRADECOMPONENTRULES Property to "1".

For example:

msiexec /fvomus path\to\minor\upgrade\product.msi REINSTALL=ALL

That command-line tells MSI toupdate the cached MSI to start the minor upgrade then do a reinstallto actually replace newer files and registry keys. The MSIENFORCEUPGRADECOMPONENTRULES Property will cause the minor upgrade to fail if you violated any of the minor upgrade rules. The log file (i.txt) should be pretty clear about what when wrong.

For quick reference I’ve pasted the minor upgrade rules from MSDN here:

  • Remove a component from a feature.

    This can also occur if you change the GUID of a component. The component identified by the original GUID appears to be removed and the component as identified by the new GUID appears as a new component.

  • *Add a new feature to the top or middle of an existing feature tree.

    The new feature must be added as a new leaf feature to an existing feature tree.

Finally, if you need to do a lot of debugging of your small updates or minor upgrades and get tired of typing in “MSIENFORCEUPGRADECOMPONENTRULES” then you can set the EnforceUpgradeComponentRules policy registry key instead.

Oh, and by the way, this little tip only works if you have MSI 3.0+ on your machine.

In the mean time, keep on coding, you know I am.