I am working on a Xamarin Forms project with Android target using Azure DevOps for CI. My project builds well in my local machine and also in the Azure Pipeline. Now, I would like to generate the code documentation with DocFx. So, I configured a powershell script to download docfx.console tool and execute it from my docfx.json file. The script works well on my local machine and the documentation is correctly generated.
I added a task in my Azure Pipeline to execute my powershell script and DocFx failed with a FileNotFoundException which concern the System.Buffers.dll file with the following logs:
[21-04-15 08:30:17.934]Info:[MetadataCommand.ExtractMetadata]Loading projects...
[21-04-15 08:30:29.096]Warning:[MetadataCommand.ExtractMetadata](D:/Path/MyProject.Android/MyProject.Android.csproj)Workspace failed with: [Failure] Msbuild failed when processing the file 'D:/Path/MyProject.Android/MyProject.Android.csproj' with message: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.EmbeddedResource.targets: (36, 5): System.IO.FileNotFoundException: Could not load file or assembly 'System.Buffers, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.
File name: 'System.Buffers, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
at Xamarin.Tools.Zip.ZipArchive.stream_callback(IntPtr state, IntPtr data, UInt64 len, SourceCommand cmd)
at Xamarin.Tools.Zip.Native.zip_source_function_create(zip_source_callback callback, IntPtr user_data, zip_error_t& errorp)
at Xamarin.Tools.Zip.ZipArchive..ctor(Stream stream, IPlatformOptions options, OpenFlags flags) in /Users/runner/work/1/s/ZipArchive.cs:line 91
at Xamarin.Tools.Zip.ZipArchive.CreateInstanceFromStream(Stream stream, OpenFlags flags, IPlatformOptions options) in /Users/runner/work/1/s/ZipArchive.Unix.cs:line 24
at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Extract(IDictionary`2 jars, ICollection`1 resolvedResourceDirectories, ICollection`1 resolvedAssetDirectories, ICollection`1 resolvedEnvironments)
at Xamarin.Android.Tasks.ResolveLibraryProjectImports.RunTask()
at Xamarin.Android.Tasks.AndroidTask.Execute()
I tried without changes to add the following app.config file next to the .csproj file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" xmlns="urn:schemas-microsoft-com:asm.v1"/>
<bindingRedirect oldVersion="4.0.2.0-4.0.3.0" newVersion="4.0.3.0" xmlns="urn:schemas-microsoft-com:asm.v1"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Informations:
DocFx version: 2.57.2
Xamarin Forms version: 5.0.0.2012
Azure Pipeline build agent: Microsoft-Hosted 'window-latest'