Travis CI continuous integration service officially supports many languages, but not C# or F#.
Can I use it with my .net projects?
Due to tight integration with GitHub, Travis CI is preferred CI/CD tool for many open source projects. Travis CI allows you to independently test pull requests & branches.
TravisCI is a cloud-based CI server. It currently has support only for GitHub repositories. To add other repositories hosted on other servers, add them as submodules. If the source code is public, one can use TravisCI for free.
We've run CI on travis-ci since 2013. We've used their free tier as an open source project. For a while they also graciously boosted our CPU performance to help sponsor us (that plan silently ended on March 6, 2021). Now, travis-ci is transitioning to their new .com domain and the current (old) .
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.
That's the key point - the project must work on Mono. This mostly works for library-style projects (AWS SDK .NET is a good example) though requires more development efforts and discipline. Linux building environment won't work if you are developing a project for Windows platform such as WPF application, Azure cloud service, Windows Phone/Store app or even ASP.NET Web API.
AppVeyor CI is a hosted continuous integration service for Windows platform and it's free for open source projects. It's like Travis CI for Windows!
You can setup build process for VS.NET solution, custom MSBuild project, PSake or any PowerShell script of batch file. Besides, AppVeyor has built-in artifacts management and deployment framework.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With