Search code examples
xamarin.iosazure-devopsmonoyamlazure-pipelines

Azure Pipeline for Xamarin Forms iOS Fails at Nuget Restore


I have searched everywhere all day long trying to get this pipeline to work.

It starts the pipeline and my tasks seem to run fine right up until I hit nuget restore for my solution. It fails with:

Unable to locate executable file: 'mono'

I have no idea why this is happening. I am using the macOS-latest vm image and I am using this task to set the mono version:

- task: Bash@3
  inputs:
    targetType: 'inline'
    script: |
      SYMLINK=6_8_0_123
      MONOPREFIX=/Library/Frameworks/Mono.framework/Versions/$SYMLINK
      echo "##vso[task.setvariable variable=DYLD_FALLBACK_LIBRARY_PATH;]$MONOPREFIX/lib:/lib:/usr/lib:$DYLD_LIBRARY_FALLBACK_PATH"
      echo "##vso[task.setvariable variable=PKG_CONFIG_PATH;]$MONOPREFIX/lib/pkgconfig:$MONOPREFIX/share/pkgconfig:$PKG_CONFIG_PATH"
      echo "##vso[task.setvariable variable=PATH;]$MONOPREFIX/bin:$PATH"

Is there something else I can set to make Nuget find the mono library?

Thanks.


Solution

  • Azure Pipeline for Xamarin Forms iOS Fails at Nuget Restore

    According to the error message:

    Unable to locate executable file: 'mono'
    

    It seems the NuGet task hasn't been implemented to work on that agent (macOS-latest) at this moment.

    To resolve above error, we could use the .NET Core (dotnet restore) task instead of nuget restore task.

    The final solution for this specific case:

    Thanks to jmichas for sharing. Use the .NET Core (dotnet restore) task indeed resolve that error. But, it brought an onslaught of other errors in specific case. The final solution for this specific case is that use the runNugetRestore in the xamarin ios build task:

    - task: XamariniOS@2
      inputs:
         runNugetRestore: true
    

    Hope this helps others.