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

发布于 2024-07-22 00:59:40 字数 33 浏览 2 评论 0原文

有没有办法使用PowerShell查看GAC的内容?

Is there a way to use PowerShell to view the contents of the GAC?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

眼角的笑意。 2024-07-29 00:59:41

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

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

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

还可以在 PowerShell 库中找到它:

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

# Show the assemblies in the GAC, including the file version
Get-GacAssembly SomeCompany* | Format-Table -View FileVersion

I had the same question. The question became more prominent with .Net 4.0 and there not being a Windows Explorer shell plugin available to view the contents. GacUtil works, but is not flexible enough and takes a lot to install. The PowerShell Community Extensions option is to limited in it's functionality and contains to many other CmdLets that I don't need. Therefore I've written my own PowerShell module to view and change the GAC. It can be found on http://powershellgac.codeplex.com

This project has moved to GitHub. You can now find it on:

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

It can also be found in the PowerShell Gallery:

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
鲜血染红嫁衣 2024-07-29 00:59:41

您只需从命令提示符即可完成此操作:

cd C:\Windows\assembly
dir

GAC 具有特定的目录结构,您不应使用命令提示符移动或删除其中的内容 - 而是使用 Windows 资源管理器 (gui) 或 gacutil (cli)

You can do it just from a command prompt:

cd C:\Windows\assembly
dir

The GAC has a specific directory structure, and you should not go moving or deleting things in there using the command prompt - rather use windows explorer (gui) or gacutil (cli)

真心难拥有 2024-07-29 00:59:41

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

另请注意,由于 MS 更改了 GAC 结构,因此您可以使用根目录中的 -Recurse 选项来搜索所有 GAC。

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

If you want to search for a specific assembly in the GAC.

Also note, since MS has changed the GAC structure you can use the -Recurse option from the root to search all the GAC.

CD C:\Windows\assembly 
ls -Recurse | ?{$_.Name -like "*log4net*"}
鱼窥荷 2024-07-29 00:59:41

我使用以下代码片段成功列出了 GAC:

New-PSDrive -Name HKCR -PSProvider 'Microsoft.PowerShell.Core\Registry' -Root HKEY_CLASSES_ROOT
Get-ItemProperty -Path 'HKCR:\Installer\Assemblies\Global' | Get-Member -MemberType NoteProperty

解决方案取自 这里

I successfully listed GAC using this code snippet:

New-PSDrive -Name HKCR -PSProvider 'Microsoft.PowerShell.Core\Registry' -Root HKEY_CLASSES_ROOT
Get-ItemProperty -Path 'HKCR:\Installer\Assemblies\Global' | Get-Member -MemberType NoteProperty

Solution taken from here.

沫尐诺 2024-07-29 00:59:40

另一种选择是 PowerShell 社区扩展 安装 GAC 提供程序,因此您可以执行以下操作:

dir gac:

如果您使用的是 PowerShell V2 ,一定要抢1.2 Beta。

Another option is that the PowerShell Community Extensions installs a GAC provider, so you can do this:

dir gac:

If you are on PowerShell V2, be sure to grab the 1.2 Beta.

夏见 2024-07-29 00:59:40

文档中所述:

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

您可能想在适当的子目录中进行搜索,甚至在这两个子目录中进行搜索。

As stated in the docs:

Starting with the .NET Framework 4, the default location for the global assembly cache is %windir%\Microsoft.NET\assembly. In earlier versions of the .NET Framework, the default location is %windir%\assembly.

You may want to search in the appropriate subdir or even in both of them.

み零 2024-07-29 00:59:40

列出 GAC 中的条目;

gacutil -l

在 powershell 中,您可以解析上面的文本输出。
我不知道有什么托管界面可以检查 GAC。

To list entries in the GAC;

gacutil -l

In powershell you could parse the text output of the above.
I don't know of a managed interface to inspect the GAC.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文