在VSTS上使用代理“托管VS2017”会在测试步骤中产生错误

时间:2017-04-28 22:21:49

标签: azure-pipelines xunit.net

到目前为止,我的构建定义配置如下:Default agent queue = Hosted和构建解决方案步骤Visual Studio Version = Visual Studio 2015。到目前为止,构建运行良好。

现在我准备在我的开发机器上迁移到Visual Studio 2017,我想看看VSTS是否能够成功运行我的构建。

因此我切换到Default agent queue = Hosted VS2017并在Build Solution步骤中转到Visual Studio Version = Visual Studio 2017

不幸的是,我在测试程序集步骤中收到以下错误。我正在使用xUnit.net进行单元测试。我目前不使用.Net Core。

Finishing: Build solution $/tfs1/Apps/Base/Base.sln
********************************************************************
Starting: Test Assemblies **\debug\*test.dll;-:**\obj\**
********************************************************************
Task         : Visual Studio Test
Description  : Run tests with Visual Studio test runner
Version      : 1.0.84
Author       : Microsoft Corporation
Help         : [More Information](https://go.microsoft.com/fwlink/?LinkId=624539)

Preparing task execution handler.
Executing the powershell script: C:\a\_tasks\VSTest_ef087383-ee5e-42c7-9a53-ab56c98420f9\1.0.84\VSTest.ps1

No results found to publish.

System.Management.Automation.CmdletInvocationException: Unable to determine the location of vstest.console.exe ---> System.IO.FileNotFoundException: Unable to determine the location of vstest.console.exe
   at Microsoft.TeamFoundation.DistributedTask.Task.Internal.InvokeVSTestCmdlet.GetVsTestLocation()
   at Microsoft.TeamFoundation.DistributedTask.Task.Internal.InvokeVSTestCmdlet.ProcessRecord()
   at System.Management.Automation.CommandProcessor.ProcessRecord()
   --- End of inner exception stack trace ---
   at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
   at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke)
   at System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, Boolean isSync)
   at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
   at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
   at Microsoft.TeamFoundation.DistributedTask.Handlers.LegacyVSTSPowerShellHost.VSTSPowerShellHost.Main(String[] args)

LegacyVSTSPowerShellHost.exe completed with return code: -1.
********************************************************************
Finishing: Test Assemblies **\debug\*test.dll;-:**\obj\**

VSTS目前还没有完全支持VS2017吗?

2 个答案:

答案 0 :(得分:2)

您需要将Visual Studio测试步骤/任务的VSTest版本更改为最新版本。

enter image description here

答案 1 :(得分:1)

对于新的构建定义(Hosted VS2017代理),您可以使用 .NET Core 任务和发布测试结果任务来代替Visual Studio Test任务。详细设置如下:

.NET Core

命令:test

项目:指定测试csproj文件,例如**/*Tests/*.csproj

参数:--configuration $(BuildConfiguration)

发布测试结果

测试结果格式:VSTest

测试结果文件:**/TEST-*.xml