Search code examples
xamaringitlabmonogitlab-cigitlab-ci-runner

Gitlab CI and Xamarin build fails


I've created a complete new Xamarin Forms App project in Visual Studio for Mac and added it to a GitLab repository. After that I created a .gitlab-ci.yml file for setting up my CI build. But the problem is that I get error messages:

error MSB4019: The imported project "/usr/lib/mono/xbuild/Xamarin/iOS/Xamarin.iOS.CSharp.targets" was not found. Confirm that the expression in the Import declaration "/usr/lib/mono/xbuild/Xamarin/iOS/Xamarin.iOS.CSharp.targets" is correct, and that the file exists on disk.

This error pops up also for Xamarin.Android.Csharp.targets.

My YML file look like this:

image: mono:latest

stages:
    - build

build:    
    stage: build
    before_script:
        - msbuild -version
        - 'echo BUILDING'
        - 'echo NuGet Restore'
        - nuget restore 'XamarinFormsTestApp.sln'
    script:        
        - 'echo Cleaning'
        - MONO_IOMAP=case msbuild 'XamarinFormsTestApp.sln' $BUILD_VERBOSITY /t:Clean /p:Configuration=Debug

Some help would be appreciated ;)


Solution

  • You will need a mac os host to build Xamarin.iOS application and AFAIK it's not there yet in GitLab. You can find the discussion here and private beta here. For now, I would recommend going your own MacOS Host and registered GitLab runner on that host:

    https://docs.gitlab.com/runner/

    You can set up the host where you want (VM or Physical device) and install the GitLab runner and Xamarin environment there, tag it and use with the GitLab pipelines as with any other shared runner.