【问题标题】:DocFx fails to load System.Buffers.dll on Azure PipelinesDocFx 无法在 Azure Pipelines 上加载 System.Buffers.dll
【发布时间】:2021-07-10 07:13:39
【问题描述】:

我正在使用 Azure DevOps for CI 开发一个带有 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, 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()

我尝试在不更改的情况下在 .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-Hosted 'window-latest'

【问题讨论】:

  • 正如您提到的脚本在您的本地机器上运行良好,您可以尝试使用自托管代理构建并检查您是否有同样的问题?
  • 很遗憾,我无法尝试使用自托管代理,因为我没有(目前也无法拥有)必要的访问权限。

标签: c# xamarin.forms xamarin.android azure-pipelines docfx


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2021-05-20
    • 2020-11-06
    • 2021-02-06
    • 2020-03-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-02
    相关资源
    最近更新 更多