6

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:

  • Paths to projects = **\*Tests*.csproj
  • Arguments = --configuration $(BuildConfiguration) --logger trx

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

Adrian Sanguineti
  • 2,455
  • 1
  • 27
  • 29

2 Answers2

11

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.

Adrian Sanguineti
  • 2,455
  • 1
  • 27
  • 29
0

FYI, this could also happen if you've got a space in one of the arguments, then it thinks there are multiple args

  • Solution then is to put the arg between qoutes – Jan Vanuytrecht Jul 03 '23 at 13:00
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Albert Einstein Jul 05 '23 at 13:47