我的powershell脚本在日志文件中运行时未报告错误,但TFS 2015构建步骤报告了错误。我需要执行特殊的回拨吗?TFS 2015构建Powershell步骤报告失败但无错误
这是一种新的样式构建,而不是基于XAML的构建。
该脚本没什么特别的,它调用robocopy,它成功发生。
这里的脚本:
[CmdletBinding()]
param (
[string]$localWorkspace,
[string]$destination
)
begin{}
process
{
try
{
## Script
$ServiceDirs = Get-ChildItem $localWorkspace -Recurse | ?{ $_.PSIsContainer -eq $True -and $_.Name -match "^Service$" } | % { $_.FullName }
$serviceCollection = @{}
foreach ($Service in $ServiceDirs)
{
$ServiceName = Get-ChildItem $Service | ?{$_.Name -match ".*\.csproj$" } | % { $_.BaseName }
$binpath = ($service + "\bin\release")
$serviceCollection.Add($serviceName , $binpath)
}
$serviceCollection.GetEnumerator() | % {
Write-Verbose "Processing service: $($_.key)"
$currentDestination = ($destination + "\" + $_.key)
$output = robocopy $_.value $currentDestination /MIR /NFL /NDL /NJH /NJS /nc /ns /np
}
}
catch
{
write-host "Caught an exception:"
write-host "Exception Type: $($_.Exception.GetType().FullName)"
write-host "Exception Message: $($_.Exception.Message)"
}
}
end{}
我可以看到所有的ROBOCOPY输出,如果我unsilence并使用/ DEBUG并没有赶上在TFS生成日志。
奇怪的是,当我强制执行错误时,执行catch并且步骤报告成功。
报告的错误信息是:
任务的PowerShell失败。这导致作业失败。查看日志 以获取更多详细信息。
您是否尝试启用调试?添加一个“system.debug”变量设置为true ... –