DocFX(在 Azure DevOps 中):找不到导入的项目“\15.0\Microsoft.Common.props”

DocFX (in Azure DevOps): The imported project "\15.0\Microsoft.Common.props" was not found

我在尝试从 Azure DevOps 构建任务生成 DocFX 文档时收到这些警告(在本地运行良好):

Build succeeded with warning.
  [19-04-25 03:02:23.747]Warning:[MetadataCommand.ExtractMetadata](d:/a/1/s/src/RailSharp/RailSharp.csproj)Workspace failed with: [Failure] Msbuild failed when processing the file 'd:\a\s\src\RailSharp\RailSharp.csproj' with message: The imported project ".0\Microsoft.Common.props" was not found. Also, tried to find ".0\Microsoft.Common.props" in the fallback search path(s) for $(MSBuildExtensionsPath) - "C:\Program Files (x86)\MSBuild" . These search paths are defined in "C:\Users\VssAdministrator\.nuget\packages\docfx.console.42.0\tools\docfx.exe.Config". Confirm that the path in the <Import> declaration is correct, and that the file exists on disk in one of the search paths.  C:\Program Files\dotnet\sdk.2.105\Sdks\Microsoft.NET.Sdk\Sdk\Sdk.props
  [19-04-25 03:02:23.747]Warning:[MetadataCommand.ExtractMetadata]Project 'd:\a\s\src\RailSharp\RailSharp.csproj' does not contain any documents.
  [19-04-25 03:02:23.747]Warning:[MetadataCommand.ExtractMetadata]No metadata is generated for RailSharp.

错误来自 dotnet build 命令(DocFX 在调用该命令时生成文档)。

这是我使用的 csproj 文件:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="docfx.console" Version="2.42.0">
      <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
      <PrivateAssets>all</PrivateAssets>
    </PackageReference>
  </ItemGroup>

</Project>

我做错了什么还是 DocFX 问题?

如果需要,这是我的代码分支:https://github.com/softframe/railsharp/tree/feature/docs

感谢 LeoLiu-MSFT 为我指明了正确的方向。 在我将 azure-pipelines.yml 中的 VM 映像设置为 vs2017-win2016 后它起作用了,如下所示:

pool:
  vmImage: vs2017-win2016

DocFX 需要 Visual Studio(或至少 VS 构建工具)才能构建文档。 因为 VS 是安装在本地而不是虚拟机映像上,所以我在 Azure DevOps 中使用(即 windows-latest),这就是它在本地工作但在 Azure DevOps 中不起作用的原因。