Scripts/Scripting.ps1
function CmxGetPendingChanges() { $result = GetPendingChanges $exitCode = $result.ExitCode if ($exitCode -ne 0) { Write-Output "ExitCode = $exitCode" Write-Output "$($result.StandardError)" Write-Output "$($result.StandardOutput)" } if ($result.ExitedInTime -eq $false) { Write-Output "The process didn't exit it time!" } [array]$changeList = ConvertPendingChangesOutputToChangeList($result.StandardOutput) Write-Output "" Write-Output "ChangeCount: $($changeList.Count)" if ($changeList.Count -gt 0) { $changeList | Format-Table LocalPath, ChangeType } } function CmxGetBuild() { $copyTarget = "$LocalWorkspace\Binaries\Release\x64_download" if (ExistsPath $copyTarget) { Read-Host "Please delete folder [$copyTarget] then retry." exit 1 } $buildFolder = GetLatestSucceededBuild if (!(ExistsPath $buildFolder)) { Read-Host "No build found." exit 1 } Write-Output "Source = $buildFolder" Write-Output "Target = $copyTarget" $result = DownloadBuild -BuildFolder "$buildFolder" -CopyTarget "$copyTarget" Write-Output "Succeeded = $($result.Succeeded)" $duration = GetReadableTimeSpan($result.TimeSpan) Write-Output "Duration = $duration" } function CmxGetLatest { [CmdletBinding()] param() Write-Output "This script gets the latest changes from the TFS server." $workspace = $LocalWorkspace $changeset = "T" # T = Gets the latest changeset Write-Output "Changeset: $changeset" Write-Output "Workspace: $workspace" Write-Output "Run preview . . . " $result = PreviewGetLatestByVersion -RootDir $workspace -ItemVersion $changeset Write-Output "Run preview has finished" if ($result.ExitCode -ne 0) { $previewResultString = "The preview detected issues, so the real command is not executed. " $previewResultString += "Please fix these issues first, then try again." Write-Output "PreviewResultString: $previewResultString" Write-Output "" Write-Output "ExitCode: $($result.ExitCode)" Write-Output "" Write-Output "Issues: " Write-Output "$($result.StandardError)" } else { $lineCount = GetLineCount($result.StandardOutput) if ($lineCount -le 1) { Write-Output "Your workspace is already up-to-date." } else { Write-Output "Run command . . . " $realResult = GetLatestByVersion -RootDir $workspace -ItemVersion $changeset Write-Output "Run command has finished" if ($realResult.ExitCode -ne 0) { $realResultString = "The command did not succeed. Please see the issues." Write-Output "RealResultString: $realResultString" Write-Output "" Write-Output "ExitCode: $($realResult.ExitCode)" Write-Output "" Write-Output "Issues: " Write-Output "$($realResult.StandardError)" } else { $realResultString = "The command succeeded." Write-Output "RealResultString: $realResultString" } } } } |