我的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 ... –