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
c # roslyn mstest vsts-build


source to share


No one has answered this question yet

Check out similar questions:

1327
Why is it important to override GetHashCode when the Equals method is overridden?
1242
When to use struct?
957
How and when to use "async and await"
789
When to use. First and when to use .FirstOrDefault with LINQ?
600
Could not find part of the path ... bin \ roslyn \ csc.exe
113
Are Roslyn's SyntaxNodes repeatable?
94
Roslyn failed to compile code
63
Using System.Dynamic in Roslyn
fourteen
Roslyn.OpenSolutionAsync () workspace. Are projects always empty?
2
Enabling Roslyn Diagnostics in Roslyn Software Analysis



All Articles
Loading...
X
Show
Funny
Dev
Pics