Follow this menu sequence:
File -> New -> Project -> ASP>NET Core Web Application (.Net Framework)
Build -> Build Solution
Get this error:
Error
In my case, the problem was that I tried to run unit tests using a dll from the ref
folder.
As described by Pavol Kovalik in https://developercommunity.visualstudio.com/solutions/1270375/view.html:
Mine was caused by having 2 Project.Tests.dll files in build artifact directory
...\Debug
net5.0
ref
Project.Tests.dll
Project.Tests.dll
Project.Tests.deps.json
As such the vstest
was discovering 2 test files. First without deps.json
file and another with it. My fix was to enforce that test file is in net*
directory (could be net5.0
or net48
in my case) like this
- script: |
dotnet vstest $(Build.BinariesDirectory)/bin/**/net*/*.Tests.dll --logger:trx
displayName: Execute unit tests