Travis CI continuous integration service officially supports many languages, but not C# or F#.
Can I use it with my .net projects?
See danielnixon's answer for the official way to do this now.
It is possible.
On your own mono machine, using the terminal, cd
into your solution directory and running the command xbuild
. This may automatically work, or it may not, as there are features you used in visual studio that need some tweaking in mono.
Things to look out for:
.csproj
linux has case sensitive paths where windows doesn't.export EnableNuGetPackageRestore=true
before running xbuild
if your project auto restores.mozroots --import --sync
to install them.nuget.*
instead of NuGet.*
references in your .csproj have been know to exist in various versions of nuget..fsproj
to trigger the VS2012 configuration on non windows machines by adding '$(VisualStudioVersion)' == '11.0' Or $(OS) != 'Windows_NT'
see example.Unable to find framework corresponding to the target framework moniker '.NETPortable,Version=v4.0,Profile=ProfileX'. Framework assembly references will be resolved from the GAC, which might not be the intended behavior.
Use Platform Conditions (mentioned under Mono 3.0.11 or earlier) or upgrade to 3.1.2.<PropertyGroup Condition="$(OS) == 'Windows_NT'"> <TargetFrameworkProfile>Profile46</TargetFrameworkProfile> </PropertyGroup>
or Condition="$(OS) != 'Windows_NT'
for mono. Your mileage may vary. See working example..ci/nunit.sh
is my own shell script for nunit testing, checked into the root of the repo. So I can install the nunit-console version I want with nuget, and configure various include/excludes of categories too. Your mileage may vary, but this technique should work for xunit etc. Or do your own thing with xbuild or fake.
#!/bin/sh -x
mono --runtime=v4.0 .nuget/NuGet.exe install NUnit.Runners -Version 2.6.1 -o packages
runTest(){
mono --runtime=v4.0 packages/NUnit.Runners.2.6.1/tools/nunit-console.exe -noxml -nodots -labels -stoponerror $@
if [ $? -ne 0 ]
then
exit 1
fi
}
#This is the call that runs the tests and adds tweakable arguments.
#In this case I'm excluding tests I categorized for performance.
runTest $1 -exclude=Performance
exit $?
For testing the latest mono it's easiest to use Mac hosts (target by using language:objective-c
Mono v3.1.2 and later changed distribution on a Mac from a DMG to just a PKG so the install is quite simple.
This template should support Portable Class Libraries, .NET 4.5.1, and FSharp 3.1.
language: objective-c
env:
global:
- EnableNuGetPackageRestore=true
matrix:
- MONO_VERSION="3.8.0"
before_install:
- wget "http://download.mono-project.com/archive/${MONO_VERSION}/macos-10-x86/MonoFramework-MDK-${MONO_VERSION}.macos10.xamarin.x86.pkg"
- sudo installer -pkg "MonoFramework-MDK-${MONO_VERSION}.macos10.xamarin.x86.pkg" -target /
script:
- xbuild
- .ci/nunit.sh Tests/bin/Debug/Tests.dll
I's easy to use Mac hosts to setup up for a build matrix for multiple versions of Mono. See script below
language: objective-c
env:
global:
- EnableNuGetPackageRestore=true
matrix:
- MONO_VER="2.10.11"
- MONO_VER="3.0.12"
before_install:
- wget "http://download.mono-project.com/archive/${MONO_VER}/macos-10-x86/MonoFramework-MDK-${MONO_VER}.macos10.xamarin.x86.dmg"
- hdid "MonoFramework-MDK-${MONO_VER}.macos10.xamarin.x86.dmg"
- sudo installer -pkg "/Volumes/Mono Framework MDK ${MONO_VER}/MonoFramework-MDK-${MONO_VER}.macos10.xamarin.x86.pkg" -target /
script:
- xbuild
- .ci/nunit.sh Tests/bin/Debug/Tests.dll
And now you should be good to go to use travis on your c# project.