Emmanuel
Posts: 17
Joined: Fri Mar 05, 2021 4:01 pm

AI_DATA_SETTER encoding

Hello,

How are encoded the custom actions in AI_DATA_SETTER? I need to encode it by myself in order to modify the xml aip file directly.

Example:
<ROW Action="AI_DATA_SETTER_12" Type="51" Source="SetEnvironmentVariables_RabbitMQ" Target="AEkAcwA2ADQAQ.....MALQBSAGEAYgBiAGkAdABNAFEAIg==">

I tried to modify the Target value with this:

Code: Select all

$StagingPath = 'C:\PkgFactory'
  $ScriptsPath = Join-Path -Path $StagingPath 'scripts'
  $configPath =  Join-Path -Path $StagingPath 'MyProject.aip'
  $Table = "caphyon.advinst.msicomp.MsiCustActComponent"

  [XML]$configXml = Get-Content -Path $configPath -ErrorAction 'Stop'

  function Set_Target{
      param (
          [String]
          $ScriptFullName
      )

    $CasName = (Get-ChildItem $ScriptFullName).BaseName

    #Get AI_DATA_SETTER number
    $AI_DATA_SETTER = $configXml.SelectNodes("//DOCUMENT/COMPONENT[@cid='$table']/ROW[@Action='$CAsName']/@AdditionalSeq") | Select-Object -ExpandProperty '#text'
    
    #Set target
    $XmlComponent = $configXml.DOCUMENT.COMPONENT | Where-Object cid -eq $Table
    $XmlRow = $XmlComponent.ROW | Where-Object Action -eq $AI_DATA_SETTER
    $CAsStringTob64 = "Is64Bit1IsFallback32BitParams" + (Get-Content($ScriptFullName))
    $CAsStringTob64 = [Convert]::ToBase64String([Text.Encoding]::unicode.GetBytes($CAsStringTob64))
    $XmlRow.Target = $CAsStringTob64 
  
    $CAsStringTob64 = [Convert]::ToBase64String([Text.Encoding]::unicode.GetBytes($CAsStringTob64))
      
    $XmlRow.Target = $CAsStringTob64 
  }

  $ScriptsList = Get-ChildItem -Path $ScriptsPath


  foreach ($Script in $ScriptsList) {
      $CasScriptFullName = $Script.FullName
      Set_Target($CasScriptFullName)
  }

  $configXml.Save($configPath)
But it doesn't work as expected... :?

Thank you for your help

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

Re: AI_DATA_SETTER encoding

Hello Emmanuel,

I have done tests on my end and it looks like the "Target" element was not encoded in the .AIP file.

In order for me to further investigate this, could you please give me some more details about your custom action?

Normally, the AI_DATA_SETTER custom action is used to set the "CustomActionData" property, to further use it on the "Deferred" stage of the installation process, since other properties are not accessible during that.

More details about this can be found in the following article: How to access installer properties from deferred custom actions.

In addition to that, could you please give me some more details about why you would need to manually edit the .AIP file? Maybe we can find a way so you do not need to do that, as it is much more complicated than using the UI and it may break the project if used incorrectly.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Emmanuel
Posts: 17
Joined: Fri Mar 05, 2021 4:01 pm

Re: AI_DATA_SETTER encoding

Hi Catalin,

Thank you for your involvement, really!

In fact, my Powershell custom actions are big. That is the reason why AI convert it to Base64 in the Target element.

Currently, I have to maintain the scripts both in the aip file (using the UI) and the script files stored on a network share.

The goal is to only maintain the script files (those on the network share) to avoid copy/paste.

Regards,

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

Re: AI_DATA_SETTER encoding

Hello Emmanuel,

You are always welcome!

Thank you for the followup on this and for sharing your scenario with me.

I believe I understand why you need this, considering the scenario.

I have discussed with our development team and they told me the reason behind the fact that we do not offer such information is exactly so the user does not manually modify the .AIP file.

This is pretty much why we have created the Command Line / PowerShell automation support.

Regarding what you want to achieve here, unfortunately, this is currently not possible.

However, I have already added (quite some time ago) on our TODO list of improvements regarding the PowerShell automation a feature request that will allow the user to create/maintain PowerShell custom actions by using our PowerShell automation support.

I believe this is what you would need in this case as well, please correct me if I'm wrong.

If that is the case, I will update this thread as soon as we will implement the improvement in Advanced Installer.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Emmanuel
Posts: 17
Joined: Fri Mar 05, 2021 4:01 pm

Re: AI_DATA_SETTER encoding

Thank you for your actions.

Impatient to use the new automation features! :-)

Regards,

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

Re: AI_DATA_SETTER encoding

You are always welcome, Emmanuel! :)

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Catalin
Posts: 6727
Joined: Wed Jun 13, 2018 7:49 am

Re: AI_DATA_SETTER encoding

Hello Emmanuel,

I have discussed with our development team and, as for this moment, it is not feasible to add "PowerShell Automation" support to add a "Run PowerShell Script Inline" custom action (from my understanding, this is the custom action you were using).

However, considering the reason you asked for such a feature:
Currently, I have to maintain the scripts both in the aip file (using the UI) and the script files stored on a network share.

The goal is to only maintain the script files (those on the network share) to avoid copy/paste.
I believe the best solution in this scenario would be to use a "Run PowerShell Script File" custom action. This way, once the script from your disk is modified, the custom action will also be modified (what I mean by this is once the project will be rebuild, the custom action will automatically point to the modified script file from your disk).

Even though, given the workaround, I think you no longer need this feature, please note it is possible to add such a custom action to your project through our "PowerShell Automation" support. For more information about this, please refer to the following thread:

Re: How to add a custom action in a project using Powershell Automation?

Hope this helps!

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
sasha
Posts: 33
Joined: Fri Oct 20, 2023 8:37 pm

Re: AI_DATA_SETTER encoding

Hello!

The problem with the encoded state of the scripts is that it's impossible to perform reviews on them. I doubt very much users manually modifying the scripts in the .aip file is such a huge problem. The inability to perform proper source/version control via code reviews is a much bigger problem.

Either stop encoding the scripts, or provide a way to decode them, my suggestion is.

AIP files are not the easiest to perform the code reviews on to begin with. Inability to see the changes in some of the most complicated parts makes things much worse.

Thanks,
.a
Catalin
Posts: 6727
Joined: Wed Jun 13, 2018 7:49 am

Re: AI_DATA_SETTER encoding

Hello,
or provide a way to decode them
In order to decode the script content, you can use an approach as it follows:
Screenshot_145.png
Screenshot_145.png (118.53 KiB) Viewed 2286 times

Hope this helps!

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
sasha
Posts: 33
Joined: Fri Oct 20, 2023 8:37 pm

Re: AI_DATA_SETTER encoding

Thanks! I did try online Base64 decoder and it returned garbage. Should've tried more.

Still, I implore you to stop the encoding, as it makes code reviews very difficult.
Catalin
Posts: 6727
Joined: Wed Jun 13, 2018 7:49 am

Re: AI_DATA_SETTER encoding

Hello,

You are always welcome!
Still, I implore you to stop the encoding, as it makes code reviews very difficult.
I will discuss this with our development team and we will see whether or not we can improve this area. :)

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
sasha
Posts: 33
Joined: Fri Oct 20, 2023 8:37 pm

Re: AI_DATA_SETTER encoding

Thank you!
Catalin
Posts: 6727
Joined: Wed Jun 13, 2018 7:49 am

Re: AI_DATA_SETTER encoding

You are always welcome! :)

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

Return to “Building Installers”