I try to run the tests for my project in Travis-CI . My project is structured like this:
.
|-- src (.NET Framework 4.7 class library)
|-- test (.NET Core 3.1 unit test project using MSTest)
I can't change the project in ./src
to .NET core.
My .travis.yml
looks like this:
language: csharp
mono: none
dotnet: 3.1.200
before_install: cd test
script:
- dotnet restore
# - dotnet add package Microsoft.NETFramework.ReferenceAssemblies.net47 --version 1.0.0
- dotnet test /p:CollectCoverage=true
The second line in the script
is something I tried but it didn't help.
It would be great if anyone could lead me to a solution for this. Or tell me that this doesn't work.
So after quite a while I got it working.
The .travis.yml
has to look like this:
language: csharp
mono: latest
dotnet: 3.1.200
before_install:
- cd src
script:
- dotnet restore
- msbuild
- dotnet test ../tests/bin/Debug/netcoreapp3.1/tests.dll
Explanation:
tests
.NET Core project and Mono to build the src
.NET 4.7 project.dotnet build
to build the .NET 4.7 project, instead the msbuild
command from Mono has to be used.dotnet test
command does only work, if the path to the tests.dll
is provided Additional notes:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.