简体   繁体   中英

Travis-CI 'Microsoft.NETCore.App', version '1.1.2' was not found

First, I'm new to Travis CI. I am trying to run tests using the DotNet Core 2.0 SDK and the 1.1.2 runtime. both 'dotnet restore' and 'dotnet build' run perfectly however 'dotnet test' fails. This works fine locally however.


Dotnet Error

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'.

Attemtps to fix

I've attempted installing the '1.1.2' shared framework runtime independenly but I cannot get this to succeed either.

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

.travis.yml

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

Edit 1

Here is the link to the latest travis build log that includes the recommended libcurl3 apt package with the same dotnet error described previously. I also updated the title and description for added clarity. - TravisCI build log

Based on this blog post , I have fixed my issue. Add the following sources and apt packages to your .travis.yml file:

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

It seems very subtle, but according to this answer on a related question you might need to add libcurl3 into your apt packages section, as dotnet restore needs it installed to be able to download the .NET Core framework.

Something like this:

addons:
  apt:
    packages:
    - libcurl3
    - ldap-utils
    - gnutls-bin
    - ssl-cert
    - slapd

Edit:

Sorry, I don't know enough about .NETCore development to help you much more. I forked your repo and tried a suggested fix , which was to set the <RuntimeFrameworkVersion> configuration property in the .csproj files to 1.1.2 , but that didn't fix anything.

It seems people working with the .NETCore Docker image are having similar issues (I guess it's close to the same as running in the TravisCI environment), and there was also a similar version mismatch issue mentioned by Scott Hanselman , though he was using a project.json file to set his library versions, and I can't see that in your repo.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM