C# Roslyn项目。在生成服务器上运行时,文档为空

C# Roslyn项目。在生成服务器上运行时,文档为空,c#,mstest,roslyn,azure-pipelines,C#,Mstest,Roslyn,Azure Pipelines,我有一个单元测试,它检查我的所有服务方法是否都调用了某个授权方法 我正在用Roslyn进行单元测试 测试在本地计算机上运行正常,但在生成服务器上失败,因为project.Documents为空 我正在使用VS 2017和mstest V2。 生成服务器是VSTS中的专用on-prem生成代理 [TestMethod] public async Task All_public_Service_Methods_should_check_authorization() { var worksp

我有一个单元测试,它检查我的所有服务方法是否都调用了某个授权方法

我正在用Roslyn进行单元测试

测试在本地计算机上运行正常,但在生成服务器上失败,因为project.Documents为空

我正在使用VS 2017和mstest V2。 生成服务器是VSTS中的专用on-prem生成代理

[TestMethod]
public async Task All_public_Service_Methods_should_check_authorization()
{
    var workspace = MSBuildWorkspace.Create();
    var project = await workspace.OpenProjectAsync(pathToCsprojFile).ConfigureAwait(false);
    Console.WriteLine($"AssemblyName is {project.AssemblyName}"); // same output
    Console.WriteLine($"FilePath is {project.FilePath}"); // same output
    Console.WriteLine($"Documents are {string.Join(Environment.NewLine,project.Documents.Select(d => d.FilePath))}"); // empty on build server
    //...
}
这是csproj,我正在加载

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

  <PropertyGroup>
    <TargetFramework>netstandard1.5</TargetFramework>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
    <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
    <DocumentationFile>bin\Debug\netstandard1.5\adremes.Exchange.Services.xml</DocumentationFile>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
    <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
    <DocumentationFile>bin\Release\netstandard1.5\adremes.Exchange.Services.xml</DocumentationFile>
  </PropertyGroup>

  <ItemGroup>
    <Folder Include="Properties\" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="adremes.Common" Version="1.4.0" />
    <PackageReference Include="AutoMapper" Version="5.2.0" />
    <PackageReference Include="AutoMapper.Collection" Version="2.1.2" />
    <PackageReference Include="DocumentFormat.OpenXml" Version="2.7.1" />
    <PackageReference Include="Microsoft.AspNetCore.Authorization" Version="1.1.1" />
    <PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="1.1.1" />
    <PackageReference Include="Microsoft.AspNetCore.Identity" Version="1.1.1" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\adremes.Exchange.Common\adremes.Exchange.Common.csproj" />
    <ProjectReference Include="..\adremes.Exchange.Data\adremes.Exchange.Data.csproj" />
  </ItemGroup>

</Project>

netstandard1.5
真的
bin\Debug\netstandard1.5\adremes.Exchange.Services.xml
真的
bin\Release\netstandard1.5\adremes.Exchange.Services.xml

不清楚您使用的是哪个生成代理、托管的VS2017、托管的还是本地生成代理(在您的计算机上安装)。我使用托管的VS2017和内部构建代理进行了测试,两者都运行良好。这是我的项目()构建定义的步骤是什么?(我为Visual Studio Build指定了Visual Studio 2017,并为Visual Studio Test指定了最新版本)您可以在此处共享详细的构建日志吗?我进行了更多的实验,发现在构建服务器上运行时,我所有的net core和netstandard项目似乎都没有文档(在prem上)如果在构建代理计算机上手动运行测试,结果会如何?我的项目结果如何?你能在OneDrive上分享一个简单的解决方案吗?你在本地机器上得到的详细结果是什么?我遇到了类似的问题。我根据示例创建了非常简单的代码:我怀疑这归结为引用的某些包(如Microsoft.Build等)的缺少/错误版本。。