[英]“PowerShell on Target Machines” task fails with an error in TFS 2017\Azure Dev Ops
I am trying to run a PowerShell script present on one of the azure server using the "PowerShell on Target Machines" Task in my TFS build definition, but the task fails with the below error.我正在尝试使用 TFS 构建定义中的“目标机器上的 PowerShell”任务运行 azure 服务器之一上存在的 PowerShell 脚本,但任务失败并出现以下错误。
System.Management.Automation.RuntimeException: The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: The specified path, file name, or both are too long.
System.Management.Automation.RuntimeException:运行命令停止,因为首选项变量“ErrorActionPreference”或公共参数设置为停止:指定的路径、文件名或两者都太长。 The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
完全限定的文件名必须少于 260 个字符,目录名必须少于 248 个字符。 --->
--->
I have copied the script in F drive but it still gives path too long error, not able to find any solution for the same.我已将脚本复制到 F 驱动器中,但它仍然给出路径太长的错误,无法找到任何解决方案。
Does anyone know what would be the reason?有谁知道是什么原因?
Added script code as well for reference,还添加了脚本代码以供参考,
GetLatestDebugOutput.ps1获取最新调试输出.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
First suggest you directly RDP to remote target machine and check if you are able to run the same script in it.首先建议您直接 RDP 到远程目标机器并检查您是否能够在其中运行相同的脚本。 This will narrow down if the issue related to your tfs build definition and environment.
如果与您的 tfs 构建定义和环境相关的问题,这将缩小范围。
For environment, make sure you have met all prerequisites of this PowerShell on Target Machines task .对于环境,请确保您已满足此PowerShell on Target Machines 任务的所有先决条件。 And you have qualified powershell version installed.
并且您已经安装了合格的 powershell 版本。
Actually the error message is pretty straight forward, and so is the key point you should pay attention to: make sure you're not using paths that are too long or using an invalidly path.实际上,错误消息非常简单,您应该注意的关键点也是如此:确保您没有使用太长的路径或使用无效的路径。 If apply for all folder and files.
如果申请所有文件夹和文件。
Besides, try starting the build with diagnostics\debug enabled with system.debug=true
and see if you can get any meaningful output for future troubleshooting.此外,尝试使用
system.debug=true
启用的 diagnostics\debug 开始构建,看看是否可以获得任何有意义的 output 以供将来故障排除。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.