全局程序集缓存工具使您可以查看和操作全局程序集缓存和下载缓存的内容。
Visual Studio 和 Windows SDK 命令提示。
-
Visual Studio Command Prompt。
- 或 -
CMD Shell)。
-
在命令提示处,键入下列命令:
gacutil [options] [assemblyName | assemblyPath | assemblyListFile]
|
参数
|
说明
|
|---|---|
|
assemblyName |
myAssembly, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0038abc9deabfle5)。 |
|
assemblyPath |
包含程序集清单的文件的名称。 |
|
assemblyListFile |
请参见本主题后面的 assemblyListFile 内容示例。 |
|
选项
|
说明
|
|---|---|
|
/cdl |
删除下载缓存的内容。 |
|
/f |
如果全局程序集缓存中已经存在同名的程序集,全局程序集缓存工具将覆盖该程序集。 |
|
/h[elp] |
显示该工具的命令语法和选项。 |
|
/i assemblyPath |
将程序集安装到全局程序集缓存中。 |
|
/if 程序集路径 |
如果全局程序集缓存中已经存在同名的程序集,全局程序集缓存工具将覆盖该程序集。 指定此选项相当于同时指定 /i 和 /f 选项。 |
|
/il assemblyListFile |
将 assemblyListFile 中指定的一个或多个程序集安装到全局程序集缓存中。 |
|
/ir 程序集路径 scheme id description |
有关可为这些参数指定的有效值的说明,请参见 /r 选项。 指定此选项相当于同时指定 /i 和 /r 选项。 |
|
/l[assemblyName] |
如果指定 assemblyName 参数,则全局程序集缓存工具只列出与该名称匹配的程序集。 |
|
/ldl |
列出下载文件缓存的内容。 |
|
/lr[assemblyName] |
如果指定 assemblyName 参数,则该工具只列出与该名称匹配的程序集及其相应的引用数。 |
|
/nologo |
取消显示 Microsoft 启动标题。 |
|
/r[assemblyName | assemblyPath] scheme id description |
与 /i、/il、/u 或 /ul 选项一起指定此选项。 若要卸载程序集,请指定assemblyName、scheme、id 和 description 参数。 如果卸载程序集,则全局程序集缓存工具还从全局程序集缓存中移除该程序集,条件是它是最后一个要移除的引用,并且 Windows Installer 没有对该程序集的未决引用。 可以指定以下值之一:
为 id 参数指定的值取决于为 scheme 参数指定的值:
当枚举引用时,显示此信息。 |
|
/silent |
取消所有输出的显示。 |
|
/uassemblyName |
从全局程序集缓存中卸载程序集。 |
|
/ufassemblyName |
通过移除对程序集的所有引用来强制卸载指定的程序集。 指定此选项相当于同时指定 /u 和 /f 选项。 如果尝试此操作,则全局程序集缓存工具显示错误信息。 |
|
/ul assemblyListFile |
从全局程序集缓存中卸载 assemblyListFile 中指定的一个或多个程序集。 |
|
/u[ngen]assemblyName |
如果指定的程序集存在现有引用数,则全局程序集缓存工具显示引用数,而且不从全局程序集缓存中移除该程序集。 注意:uninstall 命令。 Ngen.exe(本机映像生成器) 创建的程序集的本机映像。 |
|
/urassemblyName scheme id description |
有关可为这些参数指定的有效值的说明,请参见 /r 选项。 指定此选项相当于同时指定 /u 和 /r 选项。 |
|
/? |
显示该工具的命令语法和选项。 |
全局程序集缓存工具提供与 Windows shell 扩展 (Shfusion.dll) 大致相同的缓存查看功能,但它更适于生成脚本、生成文件和批处理文件。
必须具有管理员特权才能使用 Gacutil.exe。
具体说来,Gacutil.exe 使您得以将程序集安装到缓存中、从缓存中移除程序集以及列出缓存的内容。
这些选项在产品开发期间适用,但不适用于实际的产品安装。
下面的示例说明了包含要安装的程序集的文件的内容。
myAssembly1.dll myAssembly2.dll myAssembly3.dll
下面的示例说明了包含要卸载的程序集的文件的内容。
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
mydll.dll 安装到全局程序集缓存中。
gacutil /i mydll.dll
hello(只要不存在对该程序集的引用计数)。
gacutil /u hello
gacutil /u hello 命令会将这两个程序集都移除。
hello 程序集。
gacutil /u hello, Version=1.0.0.1, Culture="de",PublicKeyToken=45e343aae32233ca
assemblyList.txt 文件中指定的程序集安装到全局程序集缓存中。
gacutil /il assemblyList.txt
assemblyList.txt 文件中指定的程序集。
gacutil /ul assemblyList.txt
My Application Description。
gacutil /i /r myDll.dll UNINSTALL_KEY MyApp "My Application Description"
MyApp。
gacutil /i /r myDll.dll FILEPATH c:\applications\myApp\myApp.exe MyApp
OPAQUE 允许您自定义 id 和 description 参数。
gacutil /i /r mydll.dll OPAQUE "Insert custom application details here" "Insert Custom description information here"
如果这是对该程序集的最后一个引用,则将同时从全局程序集缓存中移除该程序集。
gacutil /u /r myDll.dll FILEPATH c:\applications\myApp\myApp.exe MyApp
下面的命令列出全局程序集缓存的内容。
gacutil /l