dougR
Posts: 21
Joined: Mon Nov 19, 2007 9:48 pm

How do I use .NET Installer Class Action for assembly in GAC

Hi -

I am testing AdvancedInstaller before I purchase it and ran into an issue where I am trying to create a .NET Install Class Action for an assembly that is being installed in the GAC.

When I create a "New Custom Action" for a .NET Installer Class Action, I can only select an installation file that is located in the Application Folder and not the GAC. Am I missing something?

If I select the file, I of course get a FileNotFoundException error because assembly is in the GAC and not the application folder and the Action Data property contains a reference to APPDIR.

Thanks.

Doug
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Hi,

Thank you for your interest in Advanced Installer.
When I create a "New Custom Action" for a .NET Installer Class Action, I can only select an installation file that is located in the Application Folder and not the GAC. Am I missing something?
Please note that you cannot use assemblies from the GAC in a custom action. In order to accomplish what you need, you must add the assembly file in the "Files and Folders" page (without adding it in the GAC) and then use it in the custom action.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
dougR
Posts: 21
Joined: Mon Nov 19, 2007 9:48 pm

How would I use InstallUtil.exe for an assembly in the GAC?

Let me back up and explain what I am trying to accomplish to see if it's even possible.

I am using Microsoft's Enterprise Library for error handling, logging and caching and want to install it into the GAC because it is strongly named and I would like to use the same version for other applications. (I recently read that strongly named assemblies that are not installed in the GAC are NGENed every time they are loaded which means a performance hit.)

And in order to properly install the Enterprise Library on a target machine, each assembly must be installed using InstallUtil.exe so I would need to run the following command for each assembly in the EntLib

%WINDIR%\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe /i Microsoft.Practices.EnterpriseLibrary.Common.dll

There is actually a batch file InstallServices.bat that comes with the Enterprise Library that can be run in order to install the assemblies.

I am able to manually run the batch file on the target machine without any errors, but when I try to include the batch file in my AdvancedInstaller project I receive the following error when trying to run it from a custom action.

---------------------------
C:\Program
---------------------------
Windows cannot find 'C:\Program'. Make sure you typed the name correctly, and then try again. To search for a file, click the Start button, and then click Search.
---------------------------
OK
---------------------------

Doug
dougR
Posts: 21
Joined: Mon Nov 19, 2007 9:48 pm

Error calling batch file from custom action

I should have mentioned that I tried to calling the batch file with additional command line arguments. (I have installed the batch file in the INSTALLDIR for now.)

[#InstallServices.bat] [WindowsFolder]assembly\gac_msi

If I run this batch file from a command window using

InstallServices.bat %WINDIR%\assembly\gac_msi

Then the assemblies are correctly installed.

Here is the section from the AIP file

Code: Select all

<COMPONENT cid="caphyon.advinst.msicomp.MsiCustActComponent">
    <ROW Action="AI_DOWNGRADE" Type="19" Target="4010"/>
    <ROW Action="AI_PREPARE_UPGRADE" Type="65" Source="aicustact.dll" Target="PrepareUpgrade"/>
    <ROW Action="AI_RESTORE_LOCATION" Type="65" Source="aicustact.dll" Target="RestoreLocation"/>
    <ROW Action="AI_STORE_LOCATION" Type="51" Source="ARPINSTALLLOCATION" Target="[APPDIR]"/>
    <ROW Action="SET_APPDIR" Type="307" Source="APPDIR" Target="[ProgramFilesFolder][Manufacturer]\[ProductName]"/>
    <ROW Action="SET_SHORTCUTDIR" Type="307" Source="SHORTCUTDIR" Target="[ProgramMenuFolder][ProductName]"/>
    <ROW Action="SET_TARGETDIR_TO_APPDIR" Type="51" Source="TARGETDIR" Target="[APPDIR]"/>
    <ROW Action="viewer.exe" Type="1538" Source="viewer.exe" Target="[#InstallServices.bat] [WindowsFolder]assembly\gac_msil"/>
  </COMPONENT>
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Hi,
Windows cannot find 'C:\Program'. Make sure you typed the name correctly, and then try again. To search for a file, click the Start button, and then click Search.
You are encountering this behavior because in the command line of your custom action you are using a path (or a reference to a file) without enclosing it in quotation marks.

Please note that a path which contains blank spaces (like "C:\Program Files") cannot be recognized unless it is enclosed by quotes ("). Let me know if the problem persists after adding the quotation marks.
If I run this batch file from a command window using
InstallServices.bat %WINDIR%\assembly\gac_msi
Then the assemblies are correctly installed.
Please note that this can also be done in Advanced Installer. You can use a "Launch file or open URL" custom action (the only one which supports BAT files) scheduled after the "InstallFiles" standard action (you can see a standard action by using the "Show Standard Action" button on the toolbar in the "Custom Actions" page).

This custom action will have the "Command Line" field set to:

Code: Select all

[#InstallServices.bat] [WindowsFolder]assembly\gac_msi
Also, please make sure that the custom action is set as Immediate in order for it to have access to the [WindowsFolder] property.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
dougR
Posts: 21
Joined: Mon Nov 19, 2007 9:48 pm

Was finally able to run the batch file

I was able to run the batch file by adding a custom action to the InstallFinalize standard action and by changing the command line of the custom action from

Code: Select all

[#InstallServices.bat] [WindowsFolder]assembly\gac_msi
to

Code: Select all

"[#InstallServices.bat]" [WindowsFolder]assembly\gac_msi
As you recommended.

Thanks.

Doug

Return to “Common Problems”