“目标机器上的PowerShell";任务失败,并在TFS 2017 \ Azure Dev Ops中出现错误 [英] "PowerShell on Target Machines" task fails with an error in TFS 2017\Azure Dev Ops

查看:100
本文介绍了“目标机器上的PowerShell";任务失败,并在TFS 2017 \ Azure Dev Ops中出现错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

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

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. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters. --->

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

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.

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

Does anyone know what would be the reason?

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

Added script code as well for reference,

GetLatestDebugOutput.ps1

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

推荐答案

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

First suggest you directly RDP to remote target machine and check if you are able to run the same script in it. This will narrow down if the issue related to your tfs build definition and environment.

对于环境,请确保已满足此

For environment, make sure you have met all prerequisites of this PowerShell on Target Machines task. And you have qualified powershell version installed.

实际上,错误消息非常简单明了,因此,您应该注意的重点是:确保您未使用过长的路径或使用了无效的路径.如果适用于所有文件夹和文件.

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.

这篇关于“目标机器上的PowerShell";任务失败,并在TFS 2017 \ Azure Dev Ops中出现错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆