【发布时间】:2020-03-08 07:14:41
【问题描述】:
我正在尝试使用我的 TFS 构建定义中的“目标计算机上的 PowerShell”任务来运行其中一台 azure 服务器上的 PowerShell 脚本,但任务失败并出现以下错误。
System.Management.Automation.RuntimeException:正在运行的命令 由于首选项变量“ErrorActionPreference”或 常用参数设置为Stop:指定路径、文件名,或 两者都太长了。全限定文件名必须小于 260 字符,并且目录名称必须少于 248 个字符。 --->
我已将脚本复制到 F 盘,但它仍然给出路径太长的错误,无法找到任何解决方案。
有人知道是什么原因吗?
还添加了脚本代码以供参考,
GetLatestDebugOutput.ps1
$DebugBuildOutput = "F:\Drops\econNextGen\SecurityScan\19.0"
$Dest = "F:\Drops\econNextGen\SecurityScan\Debug Build Output"
Remove-Item "$Dest\*" -Recurse -Force
#Code to Copy Common-App Debug Build
$Dir= $DebugBuildOutput + "\econNextGen-Common-App-Debug\"
$Latest = Get-ChildItem -Path $Dir | Sort-Object LastAccessTime -Descending | Select-Object -First 1
$FolderPath= $Dir +$Latest.Name
Copy-Item -Path $FolderPath $Dest –Recurse -force
#Code to Copy Main-App Debug Build
$Dir= $DebugBuildOutput + "\econNextGen-MAIN-APP-Debug\"
$Latest = Get-ChildItem -Path $Dir | Sort-Object LastAccessTime -Descending | Select-Object -First 1
$FolderPath= $Dir +$Latest.Name
Copy-Item -Path $FolderPath $Dest –Recurse -force
【问题讨论】:
-
你能分享你试图运行或目标机器的 .ps1 文件吗?和/或构建设置页面截图?
-
根据我使用 powershell 执行 TFS 的经验,如果您的脚本路径错误或不可接受(我的意思是这个;运行命令停止,因为首选项变量“ErrorActionPreference”或公共参数是设置为 Stop )这就是为什么文件中的脚本可能是一个重要案例
-
@JimErginbash 我已经在目标机器任务上分享了ps脚本和powershell以供参考。
标签: powershell azure-devops azure-pipelines azure-pipelines-build-task