Global Assembly Cache Tool (Gacutil.exe)
The Global Assembly Cache tool enables you to view and manipulate the global assembly cache and download cached content.
Copy
gacutil [Options] [assemblyname | assemblypath | assemblylistfile]
Parameters
Parameters |
Description |
AssemblyName |
The name of the assembly. You can provide a partial specified assembly name (such as myassembly) or a fully specified assembly name (such as myassembly, version=2.0.0.0, Culture=neutral, PublicKeyToken =0038abc9deabfle5). |
AssemblyPath |
The name of the file that contains the assembly manifest. |
assemblyListFile |
The path to the ANSI text file that lists the assemblies to install or uninstall. To install an assembly using a text file, specify the path of each assembly separately on a separate line in the file. The Global Assembly Cache tool interprets the relative path to the location in relation to the assemblyListFile . To unload an assembly by using a text file, specify the fully qualified assembly name for each assembly on a separate line in the file. See the assemblylistfile Content Example later in this topic. |
Options |
Description |
/cdl |
Delete the contents of the download cache. |
/F |
Specifying This option together with the/I or /il option forces the assembly to be reinstalled. If an assembly with the same name already exists in the global assembly cache, the Global Assembly Cache tool overwrites the assembly. |
/ H [elp] |
Displays the command syntax and options for the tool. |
/I AssemblyPath |
Installs the Assembly into the global assembly cache. |
/if AssemblyPath |
Installs the Assembly into the global assembly cache. If an assembly with the same name already exists in the global assembly cache, the Global Assembly Cache tool overwrites the assembly. Specifying this option is equivalent to specifying the/I and/ F options at the same time. |
/il assemblyListFile |
Installs one or more assemblies specified in assemblylistfile into the global assembly cache. |
/ir AssemblyPath Scheme Id Description |
Installs the Assembly into the global assembly cache and adds a reference to count the assemblies. You must specify the assemblypath,scheme,ID , and description parameters when using this option. For a description of the valid values that can be specified for these parameters, see the/ r option. Specifying this option is equivalent to specifying the/I and/ R options at the same time. |
/ L [AssemblyName] |
Lists the contents of the global assembly cache. If you specify the assemblyname parameter, the Global Assembly Cache tool lists only the assemblies that match that name. |
/ldl |
Lists the contents of the download file cache. |
/LR [AssemblyName] |
Lists all the assemblies and their corresponding reference numbers. If you specify the assemblyname parameter, the tool lists only the assemblies that match the name and their corresponding number of references. |
/nologo |
The Microsoft startup title is deselected. |
/ R [AssemblyName | AssemblyPath] Scheme Id Description |
Specifies a tracking reference to one or more assemblies to install or uninstall. Specify This option together with the/I,/il,/u , or /ul options. To install an assembly, specify the assemblypath,scheme,ID , and description parameters at the same time that you use this option. To unload an assembly, specify the AssemblyName,scheme,ID , and description parameters. To remove a reference to an assembly, you must specify the scheme,ID , and /irspecified by using the/I and/ R(or) options when installing the assembly. The description parameter. If you unload an assembly, the global Assembly Cache tool also removes the Assembly from the global assembly cache, provided that it is the last reference to remove, and that Windows Installer does not have a pending reference to the assembly. The scheme parameter specifies the type of installation scenario. You can specify one of the following values:
Uninstall_key: Specify this value if the installer adds the application to add/Remove Programs in Microsoft Windows. The application adds itself to add/Remove Programs by adding a registry key to the Hklm\software\microsoft\windows\currentversion.
FILEPATH: Specify this value if the installer does not add the application to add/Remove Programs.
OPAQUE: Specify this value if the provided registry key or file path is not appropriate for your installation scenario. This value allows you to specify custom information for the ID parameter.
The value specified for the ID parameter depends on the value specified for the scheme parameter:
If you specify Uninstall_key for the scheme parameter, specify the name of the application set in the Hklm\software\microsoft\windows\currentversion registry key. For example, if the registry key is Hklm\software\microsoft\windows\currentversion\myapp, specify MYAPP as the ID parameter.
If you specify FILEPATH for the scheme parameter, specify the full path of the executable file for the installation assembly as the ID parameter.
If you specify OPAQUE for the scheme parameter, you can supply any piece of data as an ID parameter. The data you specify must be enclosed in quotation marks ("").
The Description parameter allows you to specify descriptive text about the application to be installed. This information is displayed when the reference is enumerated. |
/silent |
Cancels the display of all outputs. |
/ u AssemblyName |
Uninstalls an assembly from the global assembly cache. |
/uf AssemblyName |
Forces the specified assembly to be unloaded by removing all references to the assembly. Specifying this option is equivalent to specifying the/ u and/ F options at the same time.
Attention |
You cannot use this option to remove an assembly that is installed by using Microsoft Windows Installer. If you try this operation, the Global Assembly Cache tool displays an error message. |
|
/ul assemblyListFile |
Unloads one or more assemblies specified in assemblylistfile from the global assembly cache. |
/u [ NGen ] AssemblyName |
Uninstalls the specified assembly from the global assembly cache. If the specified assembly has an existing number of references, the Global Assembly Cache tool displays the number of references, and the assembly is not removed from the global assembly cache.
note |
in. NET Framework version 2.0, &NBSP is not supported; /ungen . Instead, use the ; Uninstall command. |
In the. NET Framework versions 1.0 and 1.1, specify /ungen will make gacutil . exe removes the assembly from the native image cache. This cache stores the native image of the assembly that was created by using native Image Generator (Ngen.exe) . |
/ur AssemblyName Scheme Id Description |
Uninstalls a reference to the specified assembly from the global assembly cache. To remove a reference to an assembly, you must specify the scheme,ID , and /ir specified by using the/I and/R (or) options when installing the assembly. The description parameter. For a description of the valid values that can be specified for these parameters, see the/ r option. Specifying this option is equivalent to specifying both the/ u and/ R options. |
/? |
Displays the command syntax and options for the tool. |
Note
The Global Assembly Cache tool provides nearly the same cache viewing functionality as the Windows Shell Extension (Shfusion.dll), but it is more suitable for generating scripts, makefile, and batch files.
Specifically, Gacutil.exe enables you to install assemblies into the cache, remove assemblies from the cache, and list cached content.
Gacutil.exe provides the option to support reference counting, similar to the reference counting scheme supported by Windows Installer. You can use Gacutil.exe to install two applications that install the same assembly, and the Global Assembly Cache tool tracks the number of references to that assembly. As a result, the Assembly remains on the computer until the two applications are uninstalled. If you are using Gacutil.exe for the actual product installation, use the option that supports reference counting. Use the /I and/ R options at the same time to install assemblies and add references to count them. Use the/ u and/ R options to remove the reference count for an assembly. Note that reference counting is not supported by using the/I and/ u options alone. These options apply during product development, but do not apply to the actual product installation.
Use the /il or /ul option to install or unload an assembly stored in an ANSI text file. The content in the text file must be in the correct format. To install an assembly using a text file, specify the path of each assembly separately on a separate line in the file. The following example shows the contents of the file that contains the assembly that you want to install.
Copy
MyAssembly1.dll MyAssembly2.dll MyAssembly3.dll
To unload an assembly by using a text file, specify the fully qualified assembly name for each assembly on a separate line in the file. The following example shows the contents of the file that contains the assembly to unload.
Copy
Myassembly1,version=1.1.0.0,culture=en,publickeytoken=874e23ab874e23ab myassembly2,version=1.1.0.0,culture=en, Publickeytoken=874e23ab874e23ab Myassembly3,version=1.1.0.0,culture=en,publickeytoken=874e23ab874e23ab
Example
The following command installs Assembly MyDLL.DLL into the global assembly cache.
Copy
gacutil/i MyDLL.DLL
The following command removes the assembly Hellofrom the global assembly cache, as long as there is no reference count for the assembly.
Copy
gacutil/u Hello
Note that the above command may remove multiple assemblies from the assembly cache because the assembly name is not fully specified. For example, if you install the 1.0.0.0 and 3.2.2.1 two versions of Hello in the cache, the gacutil/u Hello command removes both assemblies.
Use the following example to avoid deleting multiple assemblies. This command removes only the Hello assemblies that match the fully specified version number, culture, and public key.
Copy
gacutil/u Hello, version=1.0.0.1, culture= "de", publickeytoken=45e343aae32233ca
The following command installs the assembly specified in the assemblyList.txt file into the global assembly cache.
Gacutil/il AssemblyList.txt
The following command removes the assembly specified in the assemblyList.txt file from the global assembly cache.
Gacutil/ul AssemblyList.txt
The following command installs MyDll.dll into the global assembly cache and adds references to it for evaluation. Assembly MyDll.dll is used by the application MyApp . The uninstall_key MyApp parameter specifies that MyApp be added to the registry key in Windows Add/Remove Programs. The description parameter is specified as My application Description.
Copy
gacutil/i/R myDll.dll uninstall_key MyApp "My application Description"
The following command installs MyDll.dll into the global assembly cache and adds references to it for evaluation. The scheme parameter FILEPATH and the ID parameter c:\applications\myApp\myApp.exe Specify the path to install the myDll.dll application. The description parameter is specified as MyApp.
gacutil/i/R myDll.dll FILEPATH C:\applications\myApp\myApp.exe myApp
The following command installs MyDll.dll into the global assembly cache and adds references to it for evaluation. The scheme parameter OPAQUE allows you to customize the ID and description parameters.
Copy
gacutil/i/R mydll.dll OPAQUE "Insert custom application details here" "Insert custom description information here"
The following command removes the application myApp reference to MyDll.dll . If this is the last reference to the Assembly, the Assembly will be removed from the global assembly cache at the same time.
gacutil/u/R myDll.dll FILEPATH C:\applications\myApp\myApp.exe myApp
The following command lists the contents of the global assembly cache.
Copy
gacutil/l
Overview of the Global Assembly Cache tool (Gacutil.exe) usage