首先,我是Travis CI的新手。我正在尝试使用DotNet Core 2.0 SDK和1.1.2运行时运行测试。 'dotnet restore'和'dotnet build'都运行得很好但是'dotnet test'失败了。然而,这在本地工作正常。
Test run for
MyProject.NETCore1_1.dll(.NETCoreApp,Version=v1.1)
Microsoft (R) Test Execution Command Line Tool Version 15.3.0-preview-20170628-02
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
Testhost process exited with error: It was not possible to find any compatible framework version
The specified framework 'Microsoft.NETCore.App', version '1.1.2' was not found.
- Check application dependencies and target a framework version installed at:
/
- Alternatively, install the framework version '1.1.2'.
我试图独立安装'1.1.2'共享框架运行时但我无法让它成功。
before_install:
- curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
- sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
- sudo sh -c 'echo "deb [arch=amd64]
ttps://packages.microsoft.com/repos/microsoft-ubuntu-trusty-prod trusty main" > /etc/apt/sources.list.d/dotnetdev.list'
- sudo apt-get update
- sudo wget "https://download.microsoft.com/download/D/0/2/D028801E-0802-43C8-9F9F-C7DB0A39B344/dotnet-sharedframework-ubuntu-x64.1.1.2.deb"
- sudo dpkg -i dotnet-sharedframework-ubuntu-x64.1.1.2.deb
- sudo apt-get install -f
sudo: required
dist: trusty
language: csharp
mono: none
dotnet: 2.0.0
env:
- CONFIGURATION=Release NOTHREADS= SECURITY=OFF $RUNCMD=test $PROJECT=MyProject.UnitTests.NETCore1_1.csproj
addons:
apt:
packages:
- ldap-utils
- gnutls-bin
- ssl-cert
- slapd
before_script:
- whoami
- mkdir /tmp/slapd
# start setup ssl
# prepare folders
- mkdir -p /tmp/ssl/private
- mkdir -p /tmp/ssl/certs
# generate certs/keys
- sudo certtool -p --outfile /tmp/ssl/private/ca_server.key
- sudo certtool -s --load-privkey /tmp/ssl/private/ca_server.key --template config/cert_template.conf --outfile /tmp/ssl/certs/ca_server.pem
- sudo certtool -p --sec-param low --outfile /tmp/ssl/private/ldap_server.key
- sudo certtool -c --load-privkey /tmp/ssl/private/ldap_server.key --load-ca-certificate /tmp/ssl/certs/ca_server.pem --load-ca-privkey /tmp/ssl/private/ca_server.key --template config/cert_template.conf --outfile /tmp/ssl/certs/ldap_server.pem
# permissions
- sudo usermod -aG ssl-cert travis
- sudo chown travis:ssl-cert /tmp/ssl/private/ldap_server.key /tmp/ssl/certs/ldap_server.pem /tmp/ssl/certs/ca_server.pem
- sudo chmod 640 /tmp/ssl/private/ldap_server.key /tmp/ssl/certs/ldap_server.pem /tmp/ssl/certs/ca_server.pem
# end setup ssl
# start ssl
- slapd -f config/slapd.conf -h "ldap://localhost:4389 ldaps://localhost:4636" &
# give openldap enough time to start
- sleep 5
# test to see that is running
- ldapwhoami -H ldap://localhost:4389 -D "cn=root,dc=example,dc=com" -w password
- ldapadd -h localhost:4389 -D cn=root,dc=example,dc=com -w password -f config/baseDn.ldif
script:
- dotnet restore
- dotnet build --configuration $CONFIGURATION $PROJECT
- export TRANSPORT_SECURITY=$SECURITY; dotnet $RUNCMD $PROJECT $NOTHREADS --configuration $CONFIGURATION
这是最新的travis构建日志的链接,其中包含推荐的libcurl3 apt软件包,其中包含前面描述的相同的dotnet错误。我还更新了标题和说明,以增加清晰度。 - TravisCI build log
答案 0 :(得分:3)
基于this blog post,我解决了我的问题。将以下源和apt包添加到.travis.yml文件中:
sources:
- sourceline: 'deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-trusty-prod trusty main'
key_url: 'https://packages.microsoft.com/keys/microsoft.asc'
packages:
- dotnet-hostfxr-1.0.1
- dotnet-sharedframework-microsoft.netcore.app-1.1.2
答案 1 :(得分:0)
这似乎非常微妙,但according to this answer on a related question您可能需要将libcurl3
添加到apt
包部分,因为dotnet restore
需要安装它才能下载。 NET Core框架。
这样的事情:
addons:
apt:
packages:
- libcurl3
- ldap-utils
- gnutls-bin
- ssl-cert
- slapd
编辑:
抱歉,我对.NETCore开发的了解不足以帮助您。我分叉你的repo和tried a suggested fix,这是为了将<RuntimeFrameworkVersion>
文件中的.csproj
配置属性设置为1.1.2
,但这并没有解决任何问题。
似乎与.NETCore Docker image合作的人有类似的问题(我猜它与在TravisCI环境中运行的情况差不多),并且也有类似的版本不匹配issue mentioned by Scott Hanselman,尽管他使用project.json
文件来设置他的库版本,我在你的回购中看不到。