How can you do a mass unload of Assemblies from GAC by PublicKeyToken?
Is there anyway to unload all assemblies 开发者_开发问答from the GAC that have a specific PublicKeyToken?
I am okay with the solution being command-line (gacutil.exe, etc) or via C#.
EDIT:
FYI, I can do this via Windows Explorer and going to the assembly folder and sort by public key and they select all the ones in question and right click and say uninstall. If this is the only way then fine please confirm, otherwise alternatives that could be "automated" would be nice. Thanks.
With the commandline and a little C# it's easy:
GacUtil /l
Lists all assemblies on CSV lines.
Filter this on the keytoken and feed the names to a removelist.txt
for
GacUtil /ul removelist.txt
If you like Powershell
you could use something like this:
& 'C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\gacutil.exe' /L |
where { $_ -match '^ ([\w\.]+,.*)$' } |
foreach {
if ($matches[1].contains("PublicKeyToken=d7e1d90e83a016b1")) {
& 'C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\gacutil.exe' /u $matches[1]
}
}
You could use the GAC API to code your own tool. Here is a managed version of the API.
精彩评论