部署 TestAgent 失败并出现未处理的异常
Deploy TestAgent fails with unhandled exception
TFS 发布定义中的部署测试代理任务失败,出现以下异常:
Unhandled Exception:
System.Management.Automation.PSInvalidOperationException: The
WriteObject and WriteError methods cannot be called from outside the
overrides of the BeginProcessing, ProcessRecord, and EndProcessing
methods, and they can only be called from within the same thread.
Validate that the cmdlet makes these calls correctly, or contact
Microsoft Customer Support Services. 2017-06-16T08:49:49.9634068Z
at
System.Management.Automation.MshCommandRuntime.ThrowIfWriteNotPermitted(Boolean
needsToWriteToPipeline) 2017-06-16T08:49:49.9634068Z at
System.Management.Automation.MshCommandRuntime.WriteHelper_ShouldWrite(ActionPreference
preference, ContinueStatus lastContinueStatus)
2017-06-16T08:49:49.9634068Z at
System.Management.Automation.MshCommandRuntime.WriteWarning(WarningRecord
record, Boolean overrideInquire) 2017-06-16T08:49:49.9634068Z at
System.Management.Automation.Cmdlet.WriteWarning(String text)
2017-06-16T08:49:49.9634068Z at
Microsoft.TeamFoundation.DistributedTask.Task.DistributedTestAutomation.Logger.WriteWarning(String
message) 2017-06-16T08:49:49.9634068Z at
Microsoft.TeamFoundation.DistributedTask.Task.DistributedTestAutomation.TestAgentDownloader.wc_DownloadFileCompleted(Object
sender, AsyncCompletedEventArgs e) 2017-06-16T08:49:49.9634068Z at
System.Net.WebClient.OnDownloadFileCompleted(AsyncCompletedEventArgs
e) 2017-06-16T08:49:49.9634068Z at
System.Threading.ExecutionContext.RunInternal(ExecutionContext
executionContext, ContextCallback callback, Object state, Boolean
preserveSyncCtx) 2017-06-16T08:49:49.9634068Z at
System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state, Boolean
preserveSyncCtx) 2017-06-16T08:49:49.9634068Z at
System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
2017-06-16T08:49:49.9634068Z at
System.Threading.ThreadPoolWorkQueue.Dispatch()
2017-06-16T08:49:55.4477257Z ##[error]PowerShell script completed with
255 errors.
如果未选中“更新测试代理”复选框,任务将成功执行。
这里提到的解决方案 https://github.com/Microsoft/vsts-tasks/issues/2964 and https://social.msdn.microsoft.com/Forums/sqlserver/en-US/dae4c62d-cd23-40ad-83cf-2555d37c0bb9/test-agent-deployment-failing?forum=tfsbuild 似乎也不起作用
Advanced - Update test agent
If set, and the test agent is already installed on the test
machines, the task will check if a new version of the test agent is
available.
- 首先,检查机器上是否已经安装了测试代理,
如果不是,这可能是根本原因。
- 尝试在构建中使用相同的设置部署测试代理
定义而不是发布。如果问题是,这将缩小范围
只与发布与否有关
- 查看测试代理机器中的Even Log是否有一些有用的
信息。
- 尝试将测试代理部署到另一台装有旧测试代理的机器上
安装并 "update test agent" 检查。
此外,如果您使用的是 TFS2017 update2Rc 并希望部署最新的测试代理,建议您使用 版本 2. 而不是版本 1. 用于 Visual Studio 测试代理部署任务,然后重试。
通过下载 testagent exe 并将其复制到有权访问构建代理的共享文件夹,问题已得到解决。这是在高级部分下配置的,并在测试代理位置下提供共享路径。
TFS 发布定义中的部署测试代理任务失败,出现以下异常:
Unhandled Exception: System.Management.Automation.PSInvalidOperationException: The WriteObject and WriteError methods cannot be called from outside the overrides of the BeginProcessing, ProcessRecord, and EndProcessing methods, and they can only be called from within the same thread. Validate that the cmdlet makes these calls correctly, or contact Microsoft Customer Support Services. 2017-06-16T08:49:49.9634068Z
at System.Management.Automation.MshCommandRuntime.ThrowIfWriteNotPermitted(Boolean needsToWriteToPipeline) 2017-06-16T08:49:49.9634068Z at System.Management.Automation.MshCommandRuntime.WriteHelper_ShouldWrite(ActionPreference preference, ContinueStatus lastContinueStatus) 2017-06-16T08:49:49.9634068Z at System.Management.Automation.MshCommandRuntime.WriteWarning(WarningRecord record, Boolean overrideInquire) 2017-06-16T08:49:49.9634068Z at System.Management.Automation.Cmdlet.WriteWarning(String text) 2017-06-16T08:49:49.9634068Z at Microsoft.TeamFoundation.DistributedTask.Task.DistributedTestAutomation.Logger.WriteWarning(String message) 2017-06-16T08:49:49.9634068Z at Microsoft.TeamFoundation.DistributedTask.Task.DistributedTestAutomation.TestAgentDownloader.wc_DownloadFileCompleted(Object sender, AsyncCompletedEventArgs e) 2017-06-16T08:49:49.9634068Z at System.Net.WebClient.OnDownloadFileCompleted(AsyncCompletedEventArgs e) 2017-06-16T08:49:49.9634068Z at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) 2017-06-16T08:49:49.9634068Z at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) 2017-06-16T08:49:49.9634068Z at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() 2017-06-16T08:49:49.9634068Z at System.Threading.ThreadPoolWorkQueue.Dispatch() 2017-06-16T08:49:55.4477257Z ##[error]PowerShell script completed with 255 errors.
如果未选中“更新测试代理”复选框,任务将成功执行。 这里提到的解决方案 https://github.com/Microsoft/vsts-tasks/issues/2964 and https://social.msdn.microsoft.com/Forums/sqlserver/en-US/dae4c62d-cd23-40ad-83cf-2555d37c0bb9/test-agent-deployment-failing?forum=tfsbuild 似乎也不起作用
Advanced - Update test agent
If set, and the test agent is already installed on the test machines, the task will check if a new version of the test agent is available.
- 首先,检查机器上是否已经安装了测试代理, 如果不是,这可能是根本原因。
- 尝试在构建中使用相同的设置部署测试代理 定义而不是发布。如果问题是,这将缩小范围 只与发布与否有关
- 查看测试代理机器中的Even Log是否有一些有用的 信息。
- 尝试将测试代理部署到另一台装有旧测试代理的机器上 安装并 "update test agent" 检查。
此外,如果您使用的是 TFS2017 update2Rc 并希望部署最新的测试代理,建议您使用 版本 2. 而不是版本 1. 用于 Visual Studio 测试代理部署任务,然后重试。
通过下载 testagent exe 并将其复制到有权访问构建代理的共享文件夹,问题已得到解决。这是在高级部分下配置的,并在测试代理位置下提供共享路径。