McKool
Posts: 113
Joined: Wed Jan 19, 2011 12:35 pm
Location: Darmstadt, Germany
Contact:  Website

Setting the product code GUID from the command line does not seem to work

Wed Nov 24, 2021 3:24 pm

Hello

Advance Installer v 17.1.2
Windows 10 x64

I have a script used to generate a new GUID for my project each time I build it. I was using following code successfully fopr one setup until now:

Code: Select all

        AdvancedInstaller.com /edit MyProject.aip /SetProductCode -langid 1031
        if %errorlevel% neq 0 exit
Now, I have two different setups for the same product, so I need to set the same GUID on both projects, to avoid an user of having both installed at the same time. For this I have modified my code as follow:

Code: Select all

	$guid = getGuid()
        AdvancedInstaller.com /edit MyProject1.aip /SetProductCode -langid 1031 -guid $guid
        if %errorlevel% neq 0 exit
        AdvancedInstaller.com /edit MyProject2.aip /SetProductCode -langid 1031 -guid $guid
        if %errorlevel% neq 0 exit        
My expecting is that I cannot install both setups at the same time, but it seems as AI still generates random guids for the projects and doesn't use the one passed as parameter.
Note: $guid contains a value like {77a4ad4d-6b21-4e59-970b-fcffadd7368b}, so the actuall command is as follow:

Code: Select all

AdvancedInstaller.com /edit MyProject1.aip /SetProductCode -langid 1031 -guid {77a4ad4d-6b21-4e59-970b-fcffadd7368b} 
I already read a post with a similar issue, where the solution was using the switch "-noprodcode" with SetVersion, but in my case I need to specify the GUID. Any hint on how to achieve this?

Thanks in advance.

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

Re: Setting the product code GUID from the command line does not seem to work

Thu Nov 25, 2021 10:38 am

Hello,

Unfortunately, It is not quite clear for me what your scenario is.

Are you using CMD or PowerShell to set the ProductCode GUID?

The fact that you mentioned $guid indicates that you are using PowerShell (please correct me if I'm wrong).

Also, I am not quite sure what the getGuid() function does either.

If you are using PowerShell, there are few mentions I want to make.

First of all, just calling "AdvancedInstaller.com" might not work. We need to use the "Start-Process" cmdlet to launch AdvancedInstaller.com, as it follows:
First.png
First.png (119KiB)Viewed 16041 times

Second of all, if you are using a variable for the GUID, please make sure that your function returns a string and not some other type.
Second.png
Second.png (279.75KiB)Viewed 16041 times

As you can see in the above screenshot, at a first glance everything seems correct with the first variable, but it has the "ScriptBlock" type due to the "{}" characters.

Hope this helps!

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

McKool
Posts: 113
Joined: Wed Jan 19, 2011 12:35 pm
Location: Darmstadt, Germany
Contact:  Website

Re: Setting the product code GUID from the command line does not seem to work

Thu Nov 25, 2021 11:14 am

Hello Catalin,

thanks for your answer. Here some clarifications:
Catalin wrote: Are you using CMD or PowerShell to set the ProductCode GUID?
I'm using PowerShell for getting the GUID and CMD for setting it, i.e. for calling AdvancedInstaller.com.
Catalin wrote: Also, I am not quite sure what the getGuid() function does either.
Sorry, I have let this so as getting the GUID is not the problem. I'm using a Jenkins pipeline (Groovy) - Here the actual line of code:

Code: Select all

def guid = powershell(returnStdout: true, script: ''' '{'+[guid]::NewGuid().ToString()+'}' ''')
GuidString.PNG
GuidString.PNG (5.15KiB)Viewed 16034 times
Catalin wrote: First of all, just calling "AdvancedInstaller.com" might not work. We need to use the "Start-Process" cmdlet to launch AdvancedInstaller.com
This is called not in powershell but in CMD. Here the actual lines of code:

Code: Select all

bat """
   REM "Generating Setup with version ${env.MAIN_VERSION} and GUID $guid"
   "C:\Program Files (x86)\Caphyon\Advanced Installer 17.1.2\bin\x86\AdvancedInstaller.com" /edit ${env.WORKSPACE}\\Source\\MyProject1.aip 
   /SetProductCode -langid 1031 -guid $guid
   if %errorlevel% neq 0 exit 
"""
Note that printing $guid wihtin the CMD code sucessfully shows the GUID-string.
OutputJenkins.png
OutputJenkins.png (19.82KiB)Viewed 16034 times
The call to AdvancedInstaller.com is returning OK, since the process is not stopped with any exception.

McKool
Posts: 113
Joined: Wed Jan 19, 2011 12:35 pm
Location: Darmstadt, Germany
Contact:  Website

Re: Setting the product code GUID from the command line does not seem to work

Thu Nov 25, 2021 3:26 pm

Hello again,

I have checked this calling the lines directly in powershell and also in CMD and it works. Only the call from my Jenkins server seems to have a problem, that I still cannot understand, since the call is 100% the same.

Just to be more accurate, I am calling several commands in a block. Is this maybe the problem?

Code: Select all

        REM "Generating Setup with version ${env.MAIN_VERSION} and GUID $guid"
        "C:\Program Files (x86)\Caphyon\Advanced Installer 17.1.2\bin\x86\AdvancedInstaller.com" /edit ${env.WORKSPACE}\\Source\\MyProject1.aip 
        /SetProperty VERSION_SHORT=${env.SHORT_VERSION}
        if %errorlevel% neq 0 exit
        "C:\Program Files (x86)\Caphyon\Advanced Installer 17.1.2\bin\x86\AdvancedInstaller.com" /edit ${env.WORKSPACE}\\Source\\MyProject1.aip 
        /SetProductCode -langid 1031 -guid $guid
        if %errorlevel% neq 0 exit
        "C:\Program Files (x86)\Caphyon\Advanced Installer 17.1.2\bin\x86\AdvancedInstaller.com" /edit ${env.WORKSPACE}\\Source\\MyProject1.aip 
        /SetProductCode -langid 1033 -guid $guid
        if %errorlevel% neq 0 exit        
        "C:\Program Files (x86)\Caphyon\Advanced Installer 17.1.2\bin\x86\AdvancedInstaller.com" /edit ${env.WORKSPACE}\\Source\\MyProject1.aip 
        /SetVersion ${env.MAIN_VERSION}
        if %errorlevel% neq 0 exit
        ${env.Advinst} /rebuild ${env.WORKSPACE}\\Source\\MyProject1.aip
        if %errorlevel% neq 0 exit
I will try to put all this in a AIC file and report back if this behaves different.

Best regards,
Keneth

McKool
Posts: 113
Joined: Wed Jan 19, 2011 12:35 pm
Location: Darmstadt, Germany
Contact:  Website

Re: Setting the product code GUID from the command line does not seem to work

Thu Nov 25, 2021 4:06 pm

Hello,

unfortunatelly, using an .aic file doesn't behave better. The file used is attached. The call is done as follow (CMD):

Code: Select all

"c:\Program Files (x86)\Caphyon\Advanced Installer 17.1.2\bin\x86\AdvancedInstaller.com" /execute D:/Jenkins/Source/MyProject1.aip D:/Jenkins/Source/RunCommandsSetup.aic 
Any idea what can be wrong here?
Attachments
RunCommandsSetup.zip
RunCommandsSetup.aic
(278Bytes)Downloaded 403 times

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

Re: Setting the product code GUID from the command line does not seem to work

Thu Dec 02, 2021 12:31 pm

Hello,

First of all, please accept my apologies for the delayed reply - we had few days off due to national holiday.

Regarding the issue, I can not say for sure why this is happening.

If this works outside of Jenkins as expected, then most likely the problem is with the pipeline.

I am no expert in Jenkins either, but I can try to have a look into this and see if I can find anything. However, in order for me to do this, please forward me a step-by-step test case which I can follow in order to reproduce this on my end (the more details you can provide, the better).

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

McKool
Posts: 113
Joined: Wed Jan 19, 2011 12:35 pm
Location: Darmstadt, Germany
Contact:  Website

Re: Setting the product code GUID from the command line does not seem to work

Thu Dec 02, 2021 12:38 pm

Hi Catalin,

thanks for the reply.

Please note that the AIC file used in my last post also does not work when calling it directly from the CMD (no jenkins). Can you take a look at the file? I am hopping, that using the file in jenkins will solve the problem, as the parameters will extracted from advancedinstaller.com itself instead of parsing them from the jenkins command line.

Thanks in advance,

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

Re: Setting the product code GUID from the command line does not seem to work

Fri Dec 03, 2021 3:40 pm

Hello,

Thank you for your followup on this.

Could you please give me some more details about what exactly is not working with the file of commands you provided above?

If it is the fact that your ProductCode is not set, please note that this is normal.

Basically, in the .AIC file, you are setting the version after setting the ProductCode. If you would be to do that manually in Advanced Installer, you will be prompted to generate a new ProductCode (to decide whether you want major upgrades or patches going forward).

When doing that in command line, the ProductCode is generated automatically.

So this is what happens:

- you set the ProductCode

- it is reset when the version is changed

For instance, if you were to run the command again for the same .AIP file, you will see that the ProductCode will be set as expected (since the version is not changed again).

To avoid this, you can simply use the -noprodcode parameter, as explained in the "Set Version Command" help article.

Another way would be to reverse the order of operations, e.g.:

- first set the version

- then set the ProductCode

Hope this helps!

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

McKool
Posts: 113
Joined: Wed Jan 19, 2011 12:35 pm
Location: Darmstadt, Germany
Contact:  Website

Re: Setting the product code GUID from the command line does not seem to work

Fri Dec 03, 2021 4:38 pm

Hello again,
Catalin wrote: Another way would be to reverse the order of operations, e.g.:
- first set the version
- then set the ProductCode
This was my problem. I was not aware that the SetVersion was changing the GUID again. This code is kind of old and just now I had to changed it to get an specific GUID. At the time I wrote that, I think SetVersion was not generating the GUID.

Anyway, it is working now as expected. Many thanks for your help,

Best regards,
Keneth

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

Re: Setting the product code GUID from the command line does not seem to work

Fri Dec 03, 2021 4:44 pm

You are always welcome, Keneth!

Glad everything works now.

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

Return to “Common Problems”