我有多个垂直文件夹,在每个垂直文件夹中有多个构建,我想为每个垂直选择最新的构建文件。根据配置模式选择构建号。下面的一段代码在一些垂直方向上工作正常,但不是所有垂直方向,这里垂直方向只是一个文件夹名称。
{
# Pick Build folder containing config BuildPattern
$buildFolders = (((Get-ChildItem $capLocation -Recurse)|
Sort CreatedDate |
Where-Object {$_.name.Contains($buildpattern)}))
# Extract file for each Vertical as per config value
foreach($vert in $vertical)
{
# Pick latest vertical folder under latest build
$verticalBuildLocation = ($buildFolders |
Sort CreatedDate |
Where-Object {$_.Fullname.Contains($vert)})[0]
}
}
下面的一段代码正在工作{$verticalFolder = (Get-ChildItem $capLocation | Where-Object {$.Fullname.Contains($vert)})$verticalBuildLocation = (get-childitem $verticalFolder.)FullName -Directory -递归| Where-Object {$.name.Contains($buildpattern)}| sort @{Expression={$_.CreationTime};提升= $假})[0]
}