AquaComm
Posts: 45
Joined: Wed May 06, 2020 3:25 am

Install files already on the Target machine to GAC

Mon Jun 28, 2021 1:05 am

I have read this old post viewtopic.php?t=649 and it has helped me already however being new to AI I am unsure how the following needs to be configured.

A directory already exists on the Target Machine and it contains files that need to be installed into the GAC by several of our projects.

Using AI's "Assemblies" there is no option to select a folder and insert the files contained therein into the GAC. It appears you must add individual files at design time. There is also no Custom Action to do this either.

Am I to assume that I will need to create my own Custom Action that will achieve the result I desire. If this is the case, is there an example I can use to create an appropriate dll and have it executed by AI.

Thanks.

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

Re: Install files already on the Target machine to GAC

Mon Jun 28, 2021 7:07 pm

Hello,
Am I to assume that I will need to create my own Custom Action that will achieve the result I desire. If this is the case, is there an example I can use to create an appropriate dll and have it executed by AI.
In this specific scenario, the answer would be yes, since Advanced Installers only offers the possibility to register the DLLs shipped with your setup package.

For this, I believe you could use any custom action (e.g. batch script, PowerShell script, .NET DLL, etc.).

What we need to note here is the fact that the custom action will most likely need to be run elevated (with administrator privileges).
If this is the case, is there an example I can use to create an appropriate dll and have it executed by AI.
Unfortunately, I do not have a .DLL for this, but I have played a little bit with PowerShell and here is what I have come up with:
RegisterGACPowerShell.png
RegisterGACPowerShell.png (117.1KiB)Viewed 5650 times


The above could be added in your project as a "Run Inline PowerShell Script", with the following options:

- first of all, we can schedule this after the "Add Resources" action group

- "Execution Time" set to "When the system is being modified (deferred)"

OBS: There are two reasons why we have the above execution option.

1st: By registering the DLL to GAC, we are modifying the system and it is recommended that all actions that modify the systems are scheduled during the deferred stage.

2nd: we need to run the custom action elevated

- under "Execution Options", we will need the "Run under the LocalSystem account with full privileges (no impersonation)" option (to run the custom action elevated)

Now, if you would like to go with the .DLL approach, here would be the required steps:

- develop the code that will register the .DLL files to GAC

- create the C# custom action --> "How to create fully fledged C# custom actions"

- use one of our "Call function from DLL" predefined custom actions --> "Custom Actions List"

OBS2: The options would be pretty much the same as for the PowerShell custom action.

Hope this will help!

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

Return to “Common Problems”