DocFx 无法在 Azure Pipelines 上加载 System.Buffers.dll

问题描述

我正在使用面向 CI 的 Azure DevOps 开发具有 Android 目标的 Xamarin Forms 项目。 我的项目在我的本地机器和 Azure Pipeline 中都能很好地构建。 现在,我想用 DocFx 生成代码文档。 因此,我配置了一个 powershell 脚本来下载 docfx.console 工具并从我的 docfx.json 文件中执行它。 该脚本在我的本地机器上运行良好,并且文档已正确生成

我在 Azure Pipeline 中添加一个任务来执行我的 powershell 脚本,而 DocFx 因 FileNotFoundException 而失败,该异常与 System.Buffers.dll 文件有关,其中包含以下日志:

[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,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()

我尝试在没有更改的情况下在 .csproj 文件旁边添加以下 app.config 文件

<?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>

信息:

DocFx 版本:2.57.2

Xamarin 表单版本:5.0.0.2012

Azure Pipeline 构建代理:Microsoft 托管的“window-latest”

解决方法

这个问题是在我的本地机器上被管道中较高的日志级别屏蔽的警告。最后,文档的生成效果很好。但围绕这个警告的谜团仍然存在。我关闭了这个主题,但如果有人对这个警告有想法......这仍然很奇怪

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...