LinuxCommandLibrary

gacutil

Manage .NET assemblies in Global Assembly Cache

TLDR

Install the specified assembly into GAC

$ gacutil -i [path/to/assembly.dll]
copy

Uninstall the specified assembly from GAC
$ gacutil -i [assembly_display_name]
copy

Print the content of GAC
$ gacutil -l
copy

SYNOPSIS

gacutil [options] [assembly_path | assembly_name]

Common forms:
gacutil /i <assembly_path>
gacutil /u <assembly_name>[,version[,culture[,publickeytoken]]]
gacutil /l [assembly_name]

PARAMETERS

/i <assembly_path>
    Installs an assembly into the GAC.

/u <assembly_name>[,version[,culture[,publickeytoken]]]
    Uninstalls an assembly from the GAC.

/l [<assembly_name>]
    Lists assemblies in the GAC, optionally filtered by name.

/lr
    Lists all assemblies in the GAC and their references.

/ul <assembly_list_file>
    Uninstalls assemblies listed in a specified file.

/ulr <assembly_list_file>
    Uninstalls assemblies listed in a file, respecting references.

/ldl
    Displays information about the GAC location.

/cdl
    Clears the download cache.

/gacdir <directory>
    Specifies the GAC directory (primarily for Mono environments).

/nologo
    Suppresses the startup banner and copyright message.

/silent
    Suppresses all output messages.

/validate [<assembly_path>]
    Validates GAC consistency or a specific assembly.

/check <assembly_name>
    Checks if a specific assembly is present in the GAC.

/verify [<assembly_name>]
    Verifies the strong name of assemblies in the GAC or a specific assembly.

/r <assembly_name> <reference_data>
    Adds a reference count to an assembly in the GAC.

/il <assembly_list_file>
    Installs assemblies listed in a specified file.

/ir <assembly_list_file>
    Installs assemblies listed in a file, respecting references.

/h | /?
    Displays the help message.

DESCRIPTION

gacutil is a command-line utility provided by the Mono runtime, the open-source implementation of the .NET Framework. Its primary function is to manage the Global Assembly Cache (GAC), a machine-wide code cache for .NET assemblies. The GAC stores strongly named assemblies that are shared by multiple applications. gacutil allows developers and administrators to install, uninstall, list, and verify the integrity of assemblies within the GAC. It's crucial for deploying shared .NET components on Linux systems running Mono applications, ensuring different applications can safely reference the same versions of libraries without conflicts. While modern .NET (.NET Core/.NET 5+) has largely moved away from the GAC model, gacutil remains relevant for legacy .NET Framework applications ported to Mono on Linux environments.

CAVEATS

  • Primarily used with Mono on Linux, not native .NET Core/.NET 5+ environments.
  • Requires Mono runtime to be installed.
  • Permissions: Often requires root privileges to modify the GAC.
  • Strong Naming: Only strongly named assemblies can be installed into the GAC.
  • Not typically used in modern containerized .NET Core deployments.

GLOBAL ASSEMBLY CACHE (GAC) ON LINUX

The GAC on Linux (Mono) typically resides in /usr/lib/mono/gac/ or similar paths. It's a structured directory where assemblies are placed based on their strong name, version, culture, and public key token. This structure allows for side-by-side execution of different versions of the same assembly.

STRONG NAMING

Assemblies installed in the GAC must be strongly named. This involves signing the assembly with a cryptographic key pair, which ensures unique identification, protects against tampering, and helps prevent version conflicts (DLL Hell) by allowing multiple versions of an assembly to coexist.

HISTORY

gacutil originated with the Microsoft .NET Framework on Windows. It was later implemented as part of the Mono Project to provide compatibility for .NET applications on Linux and other platforms. Its usage on Linux is almost exclusively tied to Mono, which aims to provide an open-source, cross-platform implementation of the .NET Framework. While .NET Core and subsequent .NET versions have largely deprecated the GAC concept, gacutil remains a legacy tool for managing shared assemblies in Mono environments.

SEE ALSO

mono(1), sn(1), msbuild(1)

Copied to clipboard