代码之家  ›  专栏  ›  技术社区  ›  GuyBehindtheGuy

使用PowerShell查看全局程序集缓存(GAC)的内容

  •  16
  • GuyBehindtheGuy  · 技术社区  · 17 年前

    是否有方法使用PowerShell查看GAC的内容?

    6 回复  |  直到 9 年前
        1
  •  17
  •   Keith Hill    17 年前

    另一个选择是 PowerShell Community Extensions 安装GAC提供程序,因此可以执行以下操作:

    dir gac:
    

    如果您在PowerShell v2上,请确保获取1.2测试版。

        2
  •  6
  •   Cheeso    17 年前

    在GAC中列出条目;

    gacutil -l
    

    在PowerShell中,您可以分析上面的文本输出。 我不知道要检查GAC的托管接口。

        3
  •  5
  •   Franc Drobnič    10 年前

    如上所述 the docs :

    从.NET Framework 4开始,全局程序集缓存的默认位置是%windir%\microsoft.net\assembly。在早期版本的.NET Framework中,默认位置是%windir%\assembly。

    您可能需要在适当的子目录中搜索,甚至在这两个子目录中都要搜索。

        4
  •  3
  •   Bacon Bits    9 年前

    我也有同样的问题。这个问题在.NET 4.0中变得更加突出,并且没有一个可用于查看内容的Windows资源管理器外壳插件。Gacutil可以工作,但不够灵活,安装需要很多时间。PowerShell社区扩展选项的功能有限,包含许多我不需要的其他Cmdlet。因此,我编写了自己的PowerShell模块来查看和更改GAC。它可以在 http://powershellgac.codeplex.com

    此项目已移至Github。您现在可以在以下位置找到它:

    https://github.com/LTruijens/powershell-gac

    它也可以在PowerShell库中找到:

    https://www.powershellgallery.com/packages/Gac/1.0.1

    # Show the assemblies in the GAC, including the file version
    Get-GacAssembly SomeCompany* | Format-Table -View FileVersion
    
        5
  •  1
  •   Tom Ritter    17 年前

    您只需在命令提示下执行以下操作:

    cd C:\Windows\assembly
    dir
    

    GAC有一个特定的目录结构,您不应该使用命令提示符移动或删除其中的内容,而应该使用Windows资源管理器(GUI)或gacutil(CLI)。

        6
  •  0
  •   Bruce P    10 年前

    如果要在GAC中搜索特定程序集。

    另外请注意,由于MS更改了GAC结构,您可以从根目录使用-recurse选项来搜索所有GAC。

    CD C:\Windows\assembly 
    ls -Recurse | ?{$_.Name -like "*log4net*"}
    
    推荐文章