【发布时间】:2023-04-08 11:40:01
【问题描述】:
我希望使用 powershell 脚本在当前文件夹中以调试模式列出 DLL。 是否可以这样做,请您帮助准备脚本。
谢谢@Moerwald。根据您提供的脚本和参考,已将其扩展为递归运行给定文件夹中的所有 DLL。你可以看看它。
Get-ChildItem -Filter *.dll -Recurse |
ForEach-Object {
$AssemblyName= $_.FullName;
try {
$Assembly = [Reflection.Assembly]::LoadFile($AssemblyName);
$type = [System.Type]::GetType("System.Diagnostics.DebuggableAttribute");
$debugAttribute = $Assembly.GetCustomAttributes($type,$false);
If ($debugAttribute.count -Eq 0) {} #{$_.Name + ":Release"}
Elseif ($debugAttribute[0].IsJITOptimizerDisabled -eq $false) {} #{$_.Name + ":Release"}
Else {$_.Name + ":Debug"}
} catch{ "***ERROR*** Error when loading assembly: " + $AssemblyName + $_.Exception.Message}
}
【问题讨论】:
标签: .net powershell debugging dll