gpt4 book ai didi

powershell - 无法将 'System.Object[]' 转换为参数 'System.String' 所需的类型 'Path'。指定错误

转载 作者:行者123 更新时间:2023-12-04 10:30:16 27 4
gpt4 key购买 nike

运行powershell脚本时出现以下错误

Set-Location : Cannot convert 'System.Object[]' to the type 'System.String' required by parameter 'Path'. Specified error 15-May-2018 08:31:42 method is not supported.



以下是有问题的脚本,请您建议这里有什么问题
cd $lsolutionPath
Get-ChildItem -Path "$lsolutionPath" -Filter "*Tests" -Recurse -Directory | where {$_.FullName -inotlike "*.sonarqube*"} | ForEach-Object {
$fullName = $_.FullName
$projName = $_.BaseName
write-output $projName
write-output $fullName

Write-Output "Starting Build Helper unit test run:3"
$tests = Get-ChildItem -Path "$fullName" -Recurse -Include *.dll
Write-Output "Starting Build Helper unit test run:4"
if($tests -eq $null) {
Write-Error "Could not find *Tests.dll"
return 999
}

cd $tests.Directory
Write-Output $tests.Directory
Write-Output "target args"
$targetArgs = "\""$tests\"" -nologo -parallel none -noshadow -xml \""$xUnittestResultsPath\$projName.xml\"" -nunit \""$testResultsPath\$projName.xml\"""
Write-Output "$target args"
Write-Output "###### Target Args:"**

最佳答案

$tests = Get-ChildItem -Path "$fullName" -Recurse -Include *.dll

cd $tests.Directory
cdSet-Location 的别名和 $tests包含多个dll文件,所以 $tests.directory是一个包含多个文件的数组,即显示为 System.Object[] .你不能同时变成所有的。

我不清楚你想改成哪一个,因为你有 -recurse ,所以可能有很多不同的目录。也许您需要 get-childitem ... | Select-Object -First 1或者您可能需要对它们进行循环来处理每一个。

关于powershell - 无法将 'System.Object[]' 转换为参数 'System.String' 所需的类型 'Path'。指定错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50376579/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com