I have an MSTest project that works fine when being executed with:
dotnet test --logger "trx;LogFileName=Result.trx" --settings tests.runsettings
I am also able to build a self-contained app out of it with:
dotnet publish -c Release -f netcoreapp2.1 --force --self-contained --runtime win-x64
But I have no idea how to run the tests from the produced output.
Calling
dotnet test .\ProjectName.dll --logger "trx;LogFileName=Result.trx" --settings tests.runsettings
fails with the message:
error MSB4025: The project file could not be loaded.
Any hints as how to run this self-contaiend MSTest-Project?
Recent versions (specifics needed here) of dotnet test now (2022) accept .dll files to perform test execution. See the official dotnet test documentation for details.
For earlier versions...
You are using the wrong tool:
ā ~ dotnet --help
test Runs unit tests using the test runner specified in the project.
vstest Runs Microsoft Test Execution Command Line Tool.
dotnet test
is the tool used to run unit tests defined in a given project. If you are trying to run tests out of a published dll, dotnet vstest
is the command you should us. You do that like this:
dotnet publish -o outputdir
dotnet vstest outputdir/your.dll