Reputation: 42013
I have a (private) Github/Travis CI setup and am trying to validate PRs and publish NuGet packages on a release branch.
Here's my .travis.yml
:
language: csharp
os: linux
dist: trusty
sudo: required
env: DOTNETCORE=1
dotnet: 1.0.0-preview2-003121
mono: none
before_script:
- npm install
script:
- gulp restore && gulp build && if [ $TRAVIS_BRANCH = 'v0.2' ]; then gulp package; fi
I'm using gulp to do some additional logic and build steps, but basically it invokes everything correctly.. the relevant invocations it does are:
dotnet restore
dotnet build **/project.json
The former succeeds, the latter fails for projects which target net451
. Errors look like it can't find framework assemblies, which makes sense, though I'm not sure on the best approach to resolve:
/home/travis/build/Secret/secret/src/Secret.Sample/project.json(7,52): error NU1001: The dependency mscorlib could not be resolved.
(same many times over, also for System
, System.Core
, System.Xml
...)
Here's a sample project.json
:
{
"version": "0.2.0-*",
"description": "Description..",
"dependencies": {
"NETStandard.Library": "1.6.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.1.0-alpha1-22107",
"Microsoft.AspNetCore.Mvc": "1.1.0-alpha1-22107",
"Microsoft.Extensions.Configuration.Json": "1.1.0-alpha1-22107",
"Microsoft.Extensions.Configuration.CommandLine": "1.1.0-alpha1-22107",
"Microsoft.Extensions.Options": "1.1.0-alpha1-22107",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0-alpha1-22107",
"Microsoft.Extensions.Logging.Console": "1.1.0-alpha1-22107",
"Microsoft.Extensions.Logging.Debug": "1.1.0-alpha1-22107",
"Microsoft.AspNetCore.Server.IISIntegration": "1.1.0-alpha1-22107"
},
"frameworks": {
"netstandard1.6": {
},
"net451": {
"buildOptions": {
"define": [ "SAMPLEY_ON_WINDOWS" ]
},
"dependencies": {
"Microsoft.Extensions.Logging.EventLog": "1.0.0"
}
}
}
}
I found https://github.com/aspnet/Home/issues/1090, where David F indicates "You can't build .NET Framework apps using CoreCLR today." (Nov 2015). Is that stil true, and it's as simple as that? - in which case I should use have Travis just build/test, skipping net451
, and Appveyor for build,test and deploy to NuGet?
That wouldn't be my first choice, but if so, how could I optionally tell dotnet build
to skip unsupported framework targets?
Ideally, I just need to re-jig my dependencies, or understand frameworkAssemblies
, or apt-get
something else into the build environment..?
Upvotes: 0
Views: 361
Reputation: 6168
dotnet build
and dotnet test
to skip over unsupported framework targets by using the -f
parameter, and putting in the frameworks that you do want to compile. For example, to compile net451
exclusively, you can run dotnet build -f 451
.latest
version for mono in your .travis.yml
file if you want to ensure you are compatible with the latest release of mono instead of a specific version. That desire depends on your requirements.If you'd like to see an example, here is a github repository with a .travis.yml
configuration file that builds in .NET Core & Mono on Travis CI for both Linux and Mac OSX, and .NET Core & .NET Framework on Appveyor for Windows.
Upvotes: 1
Reputation: 42013
To target .NET Framework targets e.g. net451
in Travis, you need Mono installed.
I fixed by changing mono: none
to mono: 4.0.5
.
Upvotes: 0