如何使用 travis-ci 在 linux 上构建和运行单元测试 Visual Studio 2017 ASP.net .NETCoreApp 版本 1.1
问题描述:
在 travis-ci 上调用 dotnet restore ./solution.sln
时出现错误.
I get an error when dotnet restore ./solution.sln
is called on travis-ci.
错误 MSB4019:未找到导入的项目/usr/share/dotnet/sdk/1.0.4/Sdks/Microsoft.Docker.Sdk/Sdk/Sdk.props".
error MSB4019: The imported project "/usr/share/dotnet/sdk/1.0.4/Sdks/Microsoft.Docker.Sdk/Sdk/Sdk.props" was not found.
我的.travis.yml
language: csharp
dotnet: 1.0.4
mono: none
dist: trusty
env: DOTNETCORE=1 # optional, can be used to take different code paths in your script
install:
- dotnet restore ./solution.sln --verbosity detailed
script:
- dotnet test --configuration Release --verbosity detailed
我该如何解决?
答
在对本地 ubuntu 机器进行相同研究后,我解决了 :)
After same research on a local ubuntu machine, i worked it out :)
使用 .travis.yml
文件,我的简单项目和 2 个单元测试项目使用 travis-ci 构建并运行所有单元测试.
with that .travis.yml
file my simple projects with 2 unittest projects build and runs all unit tests fine using travis-ci.
language: csharp
dotnet: 1.0.4
mono: none # is not needed
dist: trusty # Ubuntu 14.04.5 image
env: DOTNETCORE=1 # optional, can be used to take different code paths in your script
addons:
apt:
packages:
- libcurl3 # needed for 'dotnet restore'
install:
- dotnet restore ./solution.sln
script:
# - dotnet build ./solution.sln --configuration Release
- find . -name *.xUnitTests.csproj -exec dotnet test {} --configuration Release ; # build and run xunit tests