简体   繁体   中英

XamarinAndroid task in Azure DevOps pipeline failing without reason

I have a Xamarin Forms app for Android, which works perfectly fine when I build it locally in VS. I've set up a pipeline to build it in Azure DevOps, too, but the XamarinAndroid@1 task keeps failing without any actual error messages; it just stops. The corresponding "error message" in the pipeline view is just "No message found for this issue". I even added a VSBuild@1 task before, which successfully compiles all projects (including unit tests, which all succeed).

The failing task itself is nothing special, pretty default stuff:

- task: XamarinAndroid@1
  inputs:
    projectFile: '**/*droid*.csproj'
    outputDirectory: '$(outputDirectory)'
    configuration: '$(buildConfiguration)'
    jdkOption: 'JDKVersion'

It even used to work, too, before adding an indirect dependency to another library, which in turn has a few NuGet dependencies. Both NuGetToolInstaller@1 and NuGetCommand@2 also work perfectly fine in the beginning of the pipeline, finding, installing, and verifying all external packages. And as mentioned before, locally everything works fine, and even the plain VS build task has no problem building everything. I can even see in the build log of the XamarinAndroid-task that the newly added library builds without any errors. Only when it claims to build my actual Xamarin project does it silently die.

The last few lines of that build log are these:

...
CoreGenerateAssemblyInfo:
Skipping target "CoreGenerateAssemblyInfo" because all output files are up-to-date with respect to the input files.
CssG:
Skipping target "CssG" because it has no outputs.
CoreCompile:
  C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Roslyn\csc.exe /noconfig /unsafe- /checked- [... all the build options in the world ...]
  Using shared compilation with compiler from directory: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Roslyn
XamlC:
  Compiling Xaml, assembly: obj\Release\netstandard2.0\[My Main Xamarin Project].dll
Finishing: XamarinAndroid

Any pointers to what could be the problem, where to look (is it my project, a Nuget dependency, or the pipeline definition itself?), or how to at least get an error message out of this?

So after the (semi-legal ^^) discussion in the comments with @jdweng I found the culprit: I was indeed using different frameworks in the various libraries, which somehow let the pipeline build fail.

Since DevOps agent jobs (to my understanding) always run on blank, fresh VMs, legacy files could not have been a problem (plus various un-/checkings of "clean" options didn't change anything, either). It's also important to note that everything was only about the pure building (aka converting a *.sln file to an *.apk file), no actual deployment happened yet, and obviously no files were manually exchanged between local and remote machines, as everything was always built from scratch.

Detailed project structure before:

XamarinMainProject           both .Net Standard 2.0
 & XamarinMainProject.Android
'-> ViewModelLibrary              .Net Framework 4.6.1
     '-> OneCodeLibrary           .Net Framework 4.6.1
     '-> TheOtherLibrary          .Net Standard 2.0

Interestingly everything worked fine (locally AND on DevOps) when TheOtherLibrary was not included in the build. But as soon as it was referenced, the DevOps Build failed as described above, while locally everything just kept on going as expected.

Now I have recreated the two 4.6.1 projects as.Net Standard 2.0 and the pipeline is happy, too.

This of course raises several questions still:

  1. Why did it work locally (and even on DevOps with a VSBuild task), but not on DevOps for the XamarinAndroid task?
  2. Almost more importantly: Why was there no error message at all (let alone a helpful one)?
  3. Should this be reported as bug to Xamarin (and if so, any hints on where to do so)?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM