Roslyn project.Documents empty when run on build server

I have a unit Test that verifies that all my service methods make a call to some authorization method.

I am testing this in a unit Test using Roslyn.

The test runs fine on my local machine, but fails on the build server because project.Documents is empty.

I am using VS 2017 and mstest V2. The build server is the private pre-build agent in VSTS.

[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
    //...
}

      

This is the csproj I am trying to download

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

      

+3


source to share





All Articles