Ansgar
Posts: 7
Joined: Tue Apr 05, 2022 12:20 pm

Keep Product Code when setting Version

Wed Feb 21, 2024 12:18 pm

Hi,

when I set a new version in the AI UI and save the project, it gives me a message box asking me if I want to generate a new Product Code (for Major Upgrades) or keep the existing one (for Patches).
The second is what I want.

However, when trying to automate my installer updates with a Powershell script, I found that setting a version using

Code: Select all

$project.ProductDetails.Version = $version
will always silently generate new Product Codes.
Which is a bizarre behavior to me, because not only is this totally intransparent, but also, if I wanted new Product Codes, I would have called one of the functions that exist specifically for that purpose.

So how can I please just set a new version number without messing with anything else?

(My current workaround is storing the old codes and restoring them after the version change. Which is a joke, though.)

Catalin
Posts: 6506
Joined: Wed Jun 13, 2018 7:49 am

Re: Keep Product Code when setting Version

Thu Feb 22, 2024 11:07 am

Hello,

This is the default behavior when changing the Version automatically:
Screenshot_108.png
Screenshot_108.png (24.38KiB)Viewed 911 times
The workaround is quite simple, as you mentioned, to simply store the old ProductCode and then use the UpgradeProductCode method to restore the new one to the old one's value.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”