asp.net-coretfstfsbuild

Dotnet test task fails with ''MSB1008: Only one project can be specified" error after upgrade to version 2.0


The TFS instance I am working on was recently upgraded from TFS 2017 Update 1 to TFS 2018 Update 2, allowing me to change the dotnet task version used in my build definitions from 0.* to 2.*.

In doing so, the dotnet test step no longer works, returning the following error:

MSBUILD : error MSB1008: Only one project can be specified.
Switch: trx

The command it runs is:

C:\Program Files\dotnet\dotnet.exe" test <Agent_WorkFolder>\1\w\3\s\source\MySolution\MyProject.csproj --configuration release --logger trx --logger trx --results-directory <Agent_WorkFolder>\1\w\_temp

The parameters given to the task are:

Reverting the task version back to 0.*, and it runs again. What is causing this error?


Solution

  • The problem is caused by --logger trx being specified in the Arguments to the task. The newer versions of the task automatically adds this switch when executing the dotnet test command as its the output which TFS supports for reading test results. The extra argument results in the switch being given twice, so whilst MSBUILD error is unhelpful, the Switch: trx part gives a clue as to what is the problem.

    Removing the switch from the arguments resolved the problem.