我有第一个内联PowerShell脚本,其中正在过滤测试项目目录并将其值设置为名为testProjectPath
的变量。
- task: PowerShell@2
displayName: "Get tests path"
inputs:
targetType: "inline"
script: |
$testpath = Get-ChildItem -Filter *Tests.csproj -Recurse | Select-Object Directory -First 1
Write-Host "##vso[task.setvariable variable=testProjectPath]$testpath"
然后我有第二个脚本,该脚本根据我的Set-Location
变量中存在的路径尝试testProjectPath
。
- task: PowerShell@2
displayName: "Run mutations"
inputs:
targetType: "inline"
script: |
Set-Location $env:testProjectPath
但是每次我尝试运行此管道时,都会收到以下错误消息:
@{Directory=D:\a\1\s\Wms.PickingCheck.Tests}
Set-Location : Cannot find drive. A drive with the name '@{Directory=D' does not exist.
At D:\a\_temp\752e8e31-b8ac-4f43-9ee0-248f6b12577c.ps1:4 char:1
+ Set-Location $env:testProjectPath
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (@{Directory=D:String) [Set-Location], DriveNotFoundException
+ FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.SetLocationCommand
我在做什么错了?