Register assemblies to GAC using InstallShield

Cornel picture Cornel · Mar 26, 2010 · Viewed 11.4k times · Source

I have to register multiple assemblies to GAC using InstallSheild and also I need the assemblies to be copied on the INSTALLDIR also. What's the best way to do it? Also I need to call regasm.exe for an assembly; can I do this using InstallShield?

I really need a new 'component' for each assembly that has to be registered in GAC?

Answer

Christopher Painter picture Christopher Painter · Mar 27, 2010

This answer assumes you are using a Windows Installer project type.

1) Create a component for each DLL file, make it as the keyfile and set the destination folder to GlobalAssemblyCache. This instructs Windows Installer to use the MsiPublishAssemblies standard action which in turn makes calls into Fusion to register the assembly in the GAC. This is effectively what GACUTIL does for you. Remember: GACUTIL is not redistributable. If the assembly has companion files, add them as companion files to the same component.

2) If your assembly is ComVisible, create a component for each DLL, mark it as the keyfile and set the .NET ComInterop to true. This will cause the COM information to be extracted at build time, and tell Windows Installer to use the MsiPublishAssemblies standard action to write the information to the registry. Note: If you have custom user code in the registration section of the assembly this will not be captured. This is per MSDN that regasm /regfile does not execute this code path. You will have to manually enter this information into InstallShield's registry view for that component.

3) Yes, you can deploy a strong-named assembly both globally and/or privatly. Whether the private one will be seen or not depends on whether the assembly with the reference has UseSpecific set or not.