繁体   English   中英

如何使用Powershell检查目录中是否存在特定dll的pdb?

[英]How can I check a pdb for a particular dll exists in a directory using Powershell?

我有一个父目录,其中有多个项目文件夹。 如何在Powershell中检查所有项目文件夹中所有相应dll的pdb是否存在?

我尝试了以下内容,但不知道如何将pdb与特定的dll匹配。

$source = "C:\ParentDir\*"
$Dir = get-childitem $source -recurse
$List = $Dir | where-object {$_.Name -like "*.dll"}

任何帮助将不胜感激。

尝试此操作,它将输出两列,FullName,dll路径和PDB,其中包含一个布尔值,指示是否存在相应的PDB文件。

Get-ChildItem $source -Filter *.dll -Recurse | 
Select-Object FullName,@{n='PDB';e={ Test-Path ($_.FullName -replace 'dll$','pdb') -PathType Leaf }}

尝试这个:

$source = ".\Projects\"
$dlls = Get-ChildItem -Path $source -Filter *.dll -Recurse | where {!$_.PSIsContainer}
foreach ($dll in $dlls)
{ 
    $pdb = $dll.FullName.Replace(".dll",".pdb") 
    if (!(Test-Path $pdb)) { Write-Output $dll }
}

它为每个没有pdb的dll返回fileinfo(dir)对象。 使用fullname属性获取文件路径。 我在上面提供了很长的答案,以便轻松展示其工作原理。 要缩短它,请使用:

$source = ".\Projects\"
Get-ChildItem -Path $source -Filter *.dll -Recurse | where {!$_.PSIsContainer} | % { $pdb = $_.FullName.Replace(".dll",".pdb"); if (!(Test-Path $pdb)) { $_ } }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM