As any good library should do, I’m building my BCLExtensions project(extensions for the .net base class library) using PCL (Portable class library, Profile328 to be exact). It works great on my AppVeyor CI builds, which is a great .Net windows build server.
I recently discovered Travis-CI has added beta C# support so I connected it up with my GitHub prooject, which is designed to eventually work with mono anyway, and gave it a go. But no, that’s a no go. The awesome error I was getting was this cryptic thing:
Target GetReferenceAssemblyPaths: /usr/lib/mono/xbuild/12.0/bin/Microsoft.Common.targets: warning : Unable to find framework corresponding to the target framework moniker '.NETPortable,Version=v4.0,Profile=Profile328'. Framework assembly references will be resolved from the GAC, which might not be the intended behavior. /usr/lib/mono/xbuild/12.0/bin/Microsoft.Common.targets: error : PCL Reference Assemblies not installed. Task "GetReferenceAssemblyPaths" execution -- FAILED
Turns out since I’m using PCL (remember how i said i was using PCL), which the Xamarin mono bits on linux don’t come with, and there are no debian packages that contain these PCL frameworks, the bits I need are not there on the Travis build vm. It wont compile without them. Damn.
Luckily for me, thanks to some fast work from the Travis-CI guys, I got the following added to my .travis.yml file:
install: - curl -sS http://storage.bos.xamarin.com/bot-provisioning/PortableReferenceAssemblies-2014-04-14.zip > /tmp/pcl-assemblies.zip - unzip /tmp/pcl-assemblies.zip -d /tmp/pcl-assemblies && mv /tmp/pcl-assemblies/PortableReferenceAssemblies-2014-04-14 /tmp/pcl-assemblies/.NETPortable - export XBUILD_FRAMEWORK_FOLDERS_PATH=/tmp/pcl-assemblies/
They even put it in a nice PR for me. This allowed the build server to download the PCL references from Xamarin, set the environment variable for the location of the assemblies (well done xbuild for including that little gem in their source, and all my builds came to life.
The only other hurdle i had was my mstest projects wouldn’t compile, no mstest on mono. This was easily fixed by changing to xUnit, which is cross platform, and I’m loving as a test framework so far. easy to add using nuget packages and this in your .yml:
install: - nuget restore MySolution.sln - chmod +x ./packages/xunit.runners.1.9.2/tools/xunit.console.clr4.exe script: - xbuild /p:Configuration=Release ./MySolution.sln - mono ./packages/xunit.runners.1.9.2/tools/xunit.console.clr4.exe ./MyProject.Tests/bin/Release/MyProject.Tests.dll
And now today I got an update from the guys at Travis:
@csmacnz just FYI, we are now installing the new referenceassemblies-pcl Debian package from Xamarin in the Travis C# support, so this workaround shouldn’t be necessary any longer :)
So I will be able to remove all this and pretend it never happened. At least I’ve documented it in the mean-time, and know it is here if a similar issue crops up in the future.