thlucas
Posts: 10
Joined: Mon Feb 09, 2004 3:30 pm
Location: Omaha, NE
Contact: Website

Do not remove .NET Assembly .DLL from [TARGETDIR]

Is there a way to install an Assembly into the GAC and leave it in the [TARGETDIR] after the install completes?

I develop cusom controls that are used by the Visual Studio .NET 2003 IDE. These controls get compiled to a .DLL, of which I place into the .NET GLobal Assembly Cache (GAC) via the AI Assemblies interface.
In order for my control to appear in the VS.NET 2003 IDE Add References dialog, I must add some entries to the Windows Registry (HKLM):

Software\Microsoft\.NetFramework\AssemblyFolders\MyAssembly
(Default) = "[TARGETDIR]" ("C:\Program Files\C3\" after install)
Description = "My Control Description"

Upon startup, VS.NET scans all subfolders in the "AssemblyFolders" registry key for .NET Assembly DLL's - it cannot find the Assembly DLL since the MSI deletes it from the [TARGETDIR] after placing it into the GAC.

Is there a way to install an Assembly into the GAC and leave it in the [TARGETDIR] after the install completes?

I currently get around this by adding a SubFolder called ".NET GAC Support" and adding the Assembly.DLL into there (as well as the base "Application Folder" location), then specify the Assembly to add from the ".NET GAC Support" folder. The copy of the DLL in the ".NET GAC Support" gets deleted after the install. I would rather just specify 1 copy of the DLL.

Thanks - Todd
Mike
Posts: 292
Joined: Wed Jun 01, 2005 10:50 am
Location: Craiova, Romania
Contact: Website

Hi,

Currently this is the default behavior for Windows Installer technology as stated in Microsoft's Platform SDK:

http://msdn.microsoft.com/library/defau ... _cache.asp

Could you provide more details on the way this functionality should be adjusted? Also could you please point us to some documentation?

Regards,
Mihai
Mihai Bobaru
Advanced Installer Team
http://www.advancedinstaller.com
thlucas
Posts: 10
Joined: Mon Feb 09, 2004 3:30 pm
Location: Omaha, NE
Contact: Website

Hi Mike - Thanks for the quick reply.

Documentation Link: http://msdn.microsoft.com/library/defau ... ponent.asp

Take a look at the "Guidelines for Releasing a Component" section:

"Note It is important to distinguish between the directory where the new component is installed and the Global Assembly Cache (GAC). Although you might choose to install your component into the GAC for use during run time, you must also install your component into a separate directory on the user's hard drive for use during design time."

Basically, the Assembly DLL is required for run-time support (GAC copy), but is also required for design-time support ([TARGETDIR] copy) when the user is designing an application in the VS.NET IDE.

Does this answer your question?

Thanks - Todd
mat_bruges
Posts: 33
Joined: Tue Mar 11, 2008 12:28 am

I have the exact same problem.

This topic is failry old, has anything been done about this or do I need to use the same workaround (additional temp folder)?

Thanks

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

Hi,

I'm afraid that this is still not supported by Windows Installer. However, the solution is simple:
- add the assembly file twice in your project (once in the installation folder and once in any other folder)
- go to the "Assemblies" page and add the assembly copy which is not in the installation folder
- make sure that the "Install in Global Assembly Cache" option is selected in the "Destination" section

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
mat_bruges
Posts: 33
Joined: Tue Mar 11, 2008 12:28 am

Re: Do not remove .NET Assembly .DLL from [TARGETDIR]

I have used this workaround, and it works to install the files.

However, when I run the uninstall, the files are only removed from the installation folder and not from the GAC. This includes some publisher policy files.

I am doing this in a merge module, which I am calling from an enterprise project.

I now have 2 questions:

1) What should I do to ensure that ALL my files are removed during uninstall? Surely this was supposed to be the default behaviour?

2) I have already distributed 2 versions of my product to clients. When they uninstall the product or install a new version, they will have problems because the old versions are not removed from the GAC. What can I do to fix this? I would rather be able to fix this in a new setup than give my clients manual steps to remove this from the GAC.

Is there perhaps some custom action script I can use to remove these files from the GAC?

Thanks

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

Re: Do not remove .NET Assembly .DLL from [TARGETDIR]

Hi,
What should I do to ensure that ALL my files are removed during uninstall? Surely this was supposed to be the default behaviour?
The uninstall behavior of the files are completely determined by the settings used for them in the merge module. For example, .Net 2.0 assemblies require the "ProcessorArchitecture" attribute in order to be removed when the package which contains them is uninstalled. Also, files may be not be removed during an uninstall if:
- they are not registered in the MSI file (for example the files are created by a custom action, by file operations etc.)
- the component which contains them is not registered with Windows Installer
- the component which contains them is marked as "Permanent"
When they uninstall the product or install a new version, they will have problems because the old versions are not removed from the GAC. What can I do to fix this?
This can be done by using a custom action in the early stages of the new installation. This custom action can search for the files which remained and remove them if they exist.
Is there perhaps some custom action script I can use to remove these files from the GAC?
There is a sample custom action on the Microsoft support which deletes a file and a folder from the desktop. You can modify this custom action to remove the files from the GAC.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
mat_bruges
Posts: 33
Joined: Tue Mar 11, 2008 12:28 am

Re: Do not remove .NET Assembly .DLL from [TARGETDIR]

Hi Cosmin,

My assemblies do not match any of the conditions you mentioned:

- they are .NET 1.1, not 2.0
- they are not marked as permanent
- they are registered with windows installer
- they are not created using a custom action

The only thing that makes them special is that they are installed twice: first in the installation BIN folder, and then also in a "Temp GAC" folder from where I mark them as GAC assemblies. The result is that this "Temp GAC" folder is not created on the file system when the product is installed (which is fine), but the problem remains that they are never uninstalled.

Have you tried this yourself? It seems to me that this is a bug.

For the moment I have created a VBscript to remove the GAC assemblies, but this is not as simple as removing them from a normal folder. It will work now, but I anticipate to run into problems if I ever have more than 1 application that puts assemblies in the GAC. If I then use this VBscript to remove the files, they will also incorrectly remove any files that are still needed by the other application.

Can you please verify that this is a bug?

Thanks

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

Re: Do not remove .NET Assembly .DLL from [TARGETDIR]

Hi,
Have you tried this yourself? It seems to me that this is a bug.
We tested some .NET 1.1 assemblies and it seems that they are not uninstalled correctly by Windows Installer. Since the assembly installation and removal are handled by Windows Installer, this is not a bug in Advanced Installer.

Please try removing the assembly manually with Gacutil.exe and let me know what happens. It is possible that the assembly is used by another application and it cannot be uninstalled.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Feature Requests”