“目标计算机上的PowerShell”任务失败,并在TFS 2017 \ Azure Dev Ops中出现错误

我试图使用TFS构建定义中的“目标计算机上的PowerShell”任务在其中一台Azure服务器上运行PowerShell脚本,但是该任务失败并出现以下错误。

  

System.Management.Automation.RuntimeException:正在运行的命令   停止,因为首选项变量“ ErroractionPreference”或   common参数设置为Stop:指定的路径,文件名或   两者都太长了。完全合格的文件名必须小于260   字符,并且目录名称必须少于248个字符。   --->

我已将脚本复制到F驱动器中,但是它仍然给出路径太长的错误,无法找到相同的任何解决方案。

有人知道这是什么原因吗?

“目标计算机上的PowerShell”任务失败,并在TFS 2017 \ Azure Dev Ops中出现错误

还添加了脚本代码以供参考,

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
yuchen886 回答:“目标计算机上的PowerShell”任务失败,并在TFS 2017 \ Azure Dev Ops中出现错误

首先建议您直接RDP到远程目标计算机,并检查是否能够在其中运行相同的脚本。如果与您的tfs构建定义和环境有关的问题,这将缩小范围。

对于环境,请确保您已满足此PowerShell on Target Machines task的所有先决条件。并且您已经安装了合格的Powershell版本。

实际上,错误消息很简单,您应该注意的重点是:确保您使用的路径不是太长或使用的路径无效。如果适用于所有文件夹和文件。

此外,尝试从system.debug=true开始build with diagnostics\debug enabled,看看是否可以获得有意义的输出以供将来进行故障排除。

本文链接:https://www.f2er.com/3116569.html

大家都在问