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

2

7

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?

Isabeau answered 14/8, 2018 at 23:23 Comment(0)
I
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.

Isabeau answered 14/8, 2018 at 23:23 Comment(3)
I tried running dotnet test "Solution.sln" and I still get the errorForth
@JohnDemetriou, I suggest you raise a new question with the complete command and log output that is returned (like my question) to get the help you require.Isabeau
I just went with defining them manually. Too much of a hastleForth
A
0

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

Awful answered 3/7, 2023 at 13:0 Comment(2)
Solution then is to put the arg between qoutesAwful
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.Doing

© 2022 - 2024 — McMap. All rights reserved.