IanB
Posts: 14
Joined: Tue Jul 17, 2018 3:59 pm

Upgrade Code

Tue Jul 17, 2018 4:07 pm

I need to build an install which will first uninstall the existing version. The existing one was installed using Installshield. I have the upgrade guid that was used in that version but when I try to enter it in Advanced Installer I get a message saying " A new upgrade code disables major upgrades and patches for older versions".

Firstly - I really don't know what that message means in terms of is it something I should be concerned about. I'm not producing patches but do issue regular upgrades (full product release).

Secondly - there seems to be two places to enter an upgrade code, one on the Product IDs tab of Product Details, and the other under "Upgrades" and I don't understand the difference between them, I can change the one under Upgrades but get that message from the one under Product Details. What's the difference between these two? Do I actually need to change them both to my existing guid?


Thanks
Ian

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

Re: Upgrade Code

Wed Jul 18, 2018 1:47 pm

Hello Ian and welcome to our forums,

"I need to build an install which will first uninstall the existing version"

In order to achieve that, the products must have the same Upgrade Code and the product version of the software you are installing must be higher than the product version of the already installed application. This can be achievable in two ways:

1) You can change the Upgrade Code of your package created using Advanced Installer to be the same as the Upgrade Code of the product created using InstallShield. The given message which you get upon trying to change the Upgrade Code means that you will not be able to create major upgrades for the previous versions. As an example to this, let's suppose you already shipped v1.0 and v2.0 to your customers. If in v3.0, you change the Upgrade Code, the v3.0 will no longer be related to v1.0 and v2.0, thus resulting in them (v1.0 and v2.0) being unable to get any major upgrades and patch.

2) You can add the products you want to be uninstalled upon installing your new package in the "Upgrades" page. This way, you will not have to change the Upgrade Code of the package created with Advanced Installer. Please keep in mind that this is mostly used if you want to uninstall some products which are not necessarily related to your package upon installing it.

In your case, I would suggest you to change the Upgrade Code of the Advance Installer package to be the same as the Upgrade Code from the InstallShield package.

Hope this helps!

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

IanB
Posts: 14
Joined: Tue Jul 17, 2018 3:59 pm

Re: Upgrade Code

Thu Jul 19, 2018 12:08 am

Hello Catlin,
Thanks for your reply.

Lets see if I understand properly... The Upgrade code shown under "Upgrades" is used to remove the previous version. The Upgrade code under "Product Details" is given to 'this' version (the one being installed by this installer), so I can change the previous guid but not the current one?

But I don't see how that works. With Installshield there are two guids, a Product Code and an Upgrade Code. The Product Code always changes, the Upgrade Code never changes and, to me, this makes sense because then any version can be removed by any later version. But if we have different Upgrade code every time how can a user jump from Version 1 to Version 3? Surely version 3 won't be able to uninstall version 1 as it will have a different code? I'm sure I'm missing something but I just want to understand.

Regards
Ian

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

Re: Upgrade Code

Thu Jul 19, 2018 8:06 am

Hello Ian,

Well, first of all, let me explain what Product Code and Upgrade Code mean.

The ProductCode property is a unique GUID used to identify your application. This identifier varies from version to version or between different languages of the same installer.

Whereas the UpgradeCode is a GUID representing a related set of products. Different versions of an application will have the same Upgrade Code.

Let me try to give you an example, so you can better understand this. Let's say you have application A. The application A has a Product Code and an Upgrade Code related to it. If you increase the version of application A from 1.0.0 to 2.0.0, the Product Code will change and the Upgrade Code will stay the same. The Upgrade Code staying the same will allow the newer version/s of your application to search and upgrade previous versions installed on the computer.

Now let's go back to your example. From what I could understand, you already have a version of your application for which you have used InstallShield. If you want this application to be uninstalled upon installing a newer version, the Upgrade Code of the newer version must be the same as the Upgrade Code of the older version, as mentioned in the example above. This way, a related set of products will be created and everytime you will want to create a newer version, upon installing, the older versions will be uninstalled.

As for the "Upgrade" page from the "Product Information" group, it is used to specify a list of products that will be removed from the target computer when your package will be installed. By specifying an Upgrade Code in the "Upgrades" page, upon installing your application, it will search for the Upgrade Code specified there and it will uninstall the related products.

Let's give another example for a better understanding. Let's say you shipped application A to your customers. Now you have created application B and you want to uninstall application A from the target computers upon installing application B. In order to achieve this, you can go "Upgrades" page and specify the Upgrade Code of the application A. This way, upon installing application B, the setup will search for the Upgrade Code specified and will uninstall all the related products.

Now coming back to your example, I suggest you to use the the first method. You should get the Upgrade Code from the application installed using InstallShield and copy it over to your Advance Installer project, in "Product Details" page --> "Product ID's" tab.

Now let me try to explain the message you are getting upon trying to change the Upgrade Code from the "Product Details" page. I will do this with another example. Let's say you have your application A installed using InstalShield and application B installed using Advanced Installer. Let's say our application B has two already existing versions, B1.0 and B2.0. If you try to create B3.0 which you want to uninstall application A, you have to change the Upgrade Code of application B3.0 to be the same as the Upgrade Code of the application A. But by doing this, B3.0 will no longer be related to B1.0 and B2.0, thus you will not be able to upgrade B1.0 and B2.0. You should not be concerned about this message, since you have only your first application (the one installed using InstallShield) and the second application (a higher version of the first application, but installed using Advanced Installer). This could concern you if you already had more versions of the application installed using Advanced Installer shipped, but that is not the case.

Hope this helps!

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

makumazan84
Posts: 12
Joined: Mon Aug 28, 2023 2:32 pm

Re: Upgrade Code

Mon Aug 28, 2023 3:00 pm

Guys, I'm a newbie in AI world so your help is greatly appreciated.

Short question: how can I define an arbitrary custom UpgradeCode from a Build Server parameter (e.g. Jenkins) and pass it to MSI correctly?

What Do I want?
I want a following scenario to work:
  • 1. Pass a custom param for UpgradeCode as AdvancedInstaller's command line param in Jenkins
    2. If a param is empty then leave AIP's UpgradeCode default value, otherwise
    3. Set AIP's UpgradeCode param to the one from Build Server.
    4. Once the installation is complete, non-null parameter must replace Upgrade Code, or leave a default UpgradeCode if it is null
    5. Of course, this custom UpgradeCode should actually distinguish different instances of our app
What have I tried so far?
  • 1. Pass a custom param called 'USR_Upgrade_Code' as AdvancedInstaller's command line param in Jenkins
    2. Create a CustomStep (PowerShell inline script) in AI with a following logic: If 'USR_Upgrade_Code' is NOT null or empty then set AIP's 'UpgradeCode' value to 'USR_Upgrade_Code'
Although the value of UpgradeCode is being set correctly (I've added logs to PS custom step) an old (default) UpgradeCode is still being used once the app is installed. I've tried to put this custom steps at the start of 'Install Execution Stage' but evidently it did not help

Custom Step's code (I've tried many options, none seem to work):

Code: Select all

# -usr_upgrade_code [USR_UPGRADE_CODE]
# Block for declaring the script parameters.
Param($usr_upgrade_code)

$convertedValue = [System.guid]::New($usr_upgrade_code)

if ($convertedValue)
{		
    AI_SetMsiProperty UpgradeCode $convertedValue
}
What am I doing wrong here?

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

Re: Upgrade Code

Mon Aug 28, 2023 3:51 pm

Hello and welcome to our forums,

Please note that these properties (ProductCode and UpgradeCode) need to be set before actually building the MSI package.

In your case, you set it during the installation process and that's why it doesn't take effect.

In order to achieve what you want, we can use the PowerShell Automation Support, e.g.:
Screenshot_44.png
Screenshot_44.png (61.67KiB)Viewed 7494 times

Code: Select all

$advinst = new-object -comobject AdvancedInstaller
$proj = $advinst.LoadProject("C:\Users\Catalin\Desktop\Your Application.aip")
$prodDetails = $proj.ProductDetails
# the get-member (gm) is used here to see if there's any method to generate a new UpgradeCode
$prodDetails.UpgradeCode | gm
$prodDetails.UpgradeCode
$prodDetails.UpgradeCode.GenerateUpgradeCode()
This way, a new UpgradeCode should be used. Of course, you can add additional logic here.

Also, after all is done, we should build the project.

Hope this helps!

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

makumazan84
Posts: 12
Joined: Mon Aug 28, 2023 2:32 pm

Re: Upgrade Code

Wed Aug 30, 2023 3:37 pm

Thank you very much, Catalin!
However, I've encountered 2 problems:
1) Although

Code: Select all

$prodDetails.UpgradeCode.GenerateUpgradeCode()
does work and generates a new UpgradeCode, setting a property manually

Code: Select all

$prodDetails.UpgradeCode = "XXX-XXXX-...."
does not work due to 'Could not find member' exception. Get-Member tells me that the setter is there, so do I need to use Set-Property?
2) Even if I generate a new UpgradeCode via

Code: Select all

GenerateUpgradeCode()
this change is not saved to an actual *.aip file. Do you know how can I save this changed code?

makumazan84
Posts: 12
Joined: Mon Aug 28, 2023 2:32 pm

Re: Upgrade Code

Thu Aug 31, 2023 7:59 am

Update: I was able to save the changes from object to project file via $proj.Save().
Setting UpgradeCode manually still remains unsolved

makumazan84
Posts: 12
Joined: Mon Aug 28, 2023 2:32 pm

Re: Upgrade Code

Thu Aug 31, 2023 8:38 am

Sorry, my fault: I've missed error in

Code: Select all

$prodDetails.UpgradeCode.UpgradeCode
Thanks for your help Catalin. I'd advise to add $project save to your snippet to actually save changes to a file.

makumazan84
Posts: 12
Joined: Mon Aug 28, 2023 2:32 pm

Re: Upgrade Code

Thu Aug 31, 2023 9:17 am

A follow up question: once I've updated the $project file via Save() I've started to get a following error:
"This project (fragment) was edited with a newer version of Advanced Installer (20.7.1) and cannot be loaded"

I know that *.aip was created using 17.9. Does it mean that remote box utilizes a 20.7.1 "Advanced Installer Toolkit" (or whatever it is called) which is used to manipulate with project via PowerShell? If so, is there any way to save the project in 17.9 compatible mode?

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

Re: Upgrade Code

Thu Aug 31, 2023 11:51 am

Hello,

First of all, thank you for your followup on this!

I am glad you managed to get this working.

Regarding the "Save" method, I had a note that mentioned we should "Build" the project, which would automatically save it as well.

Now, regarding your latest issue, I am not quite sure why that is happening. Have you perhaps edited your Advanced Installer project in a newer version on another machine?

If not, perhaps you can give me the steps so i can test this on my end?

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

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

Re: Upgrade Code

Thu Aug 31, 2023 11:57 am

Hello,

As a followup to this, if you have two versions of Advanced Installer installed on the machine, please have a look over the following article which should help you use the 17.9 COM object instead of the 20.7 one.

Re: PowerShell build problems

However, I am not sure all the options will be available there - because this feature is in a constant state of improvement and these improvements are added in newer versions.

Hope this helps!

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

makumazan84
Posts: 12
Joined: Mon Aug 28, 2023 2:32 pm

Re: Upgrade Code

Thu Aug 31, 2023 12:21 pm

Hi, Catalin!

"Now, regarding your latest issue, I am not quite sure why that is happening. Have you perhaps edited your Advanced Installer project in a newer version on another machine?
If not, perhaps you can give me the steps so i can test this on my end?"

Yes, that's exactly what has happened:
1) I've got an aip project file created in 17.9 locally
2) This file is modified on Jenkins box which contains multiple versions of AI via the code snippet we've discussed earlier:

Code: Select all

$advinst = new-object -comobject AdvancedInstaller
	$proj = $advinst.LoadProject("C:\Path\DesktopClient.aip")
	$prodDetails = $proj.ProductDetails
	$prodDetails.UpgradeCode.UpgradeCode = "XXXX..."
	$proj.Save()
The project is edited via an instance of COM object 'AdvancedInstaller'. I'm pretty sure that by default AdvancedInstaller COM Object's version is 20.7
In a perfect scenario, I'd like to be able to pass a version to the code, or use some other way to create an version specific instance of AdvancedInstaller COM class

Code: Select all

$advinst = new-object -comobject AdvancedInstaller
I've seen your solution (register COM Server of needed version via /REGSERVER). I'll check with our env engineers if this doesn't break other builds which other teams might use.
But still, being able to pass a version during object's creation would be perfect (if possible at all)

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

Re: Upgrade Code

Fri Sep 01, 2023 9:51 am

Hello,

Thank you for your followup on this and for the explanation!
The project is edited via an instance of COM object 'AdvancedInstaller'. I'm pretty sure that by default AdvancedInstaller COM Object's version is 20.7
You are indeed right about this. By default, the newest COM is used.

The only scenario where this does not happen is when you register the older COM (only one can be used at a time).
I've seen your solution (register COM Server of needed version via /REGSERVER). I'll check with our env engineers if this doesn't break other builds which other teams might use.
Please do. Normally, this shouldn't really affect the build environment at all.

The only thing to be kept in mind here would be what I've said before - i.e. only one COM can be registered at a time. This being said, if you then want to build a project in 20.7, the 20.7 COM must be registered.

Regarding your request, it indeed would be ideal, but I'm afraid it may not be possible for us to do so as the COM can not be "versioned" - this is once again related to the above (that only one COM can be registered at a time).

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

makumazan84
Posts: 12
Joined: Mon Aug 28, 2023 2:32 pm

Re: Upgrade Code

Mon Sep 04, 2023 2:16 pm

Hi, Catalin!

To resolve COM versioning issue we've switched to the latest available 20.9.1 which builds fine and seems to work fine.
However, I'm still getting a warning 'This package has been created using a Trial Version of Advanced Installer. You may use it for evaluational purposes only' (which is not true since both our 17.9 and 20.9.1 versions are fully licensed).
I've read an older support article viewtopic.php?t=28627 asking to rebuild the *.aip with the licensed AI but this is exactly what we're doing anyways.
Could you pls advise me on removing this warning?

Return to “Building Installers”