Skip to content

Index was out of range. VSTS #179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
j2ghz opened this issue Aug 22, 2018 · 6 comments
Closed

Index was out of range. VSTS #179

j2ghz opened this issue Aug 22, 2018 · 6 comments

Comments

@j2ghz
Copy link

j2ghz commented Aug 22, 2018

The VSTS agent is running in docker, image: microsoft/vsts-agent:ubuntu-16.04-standard. The same test command works locally. I found #135 but I'm not using multiple output formats.

2018-08-22T07:24:52.2980413Z 09:19:02.029   1:7>Target "GenerateCoverageResult: (TargetId:266)" in file "/root/.nuget/packages/coverlet.msbuild/2.2.1/build/netstandard2.0/coverlet.msbuild.targets" from project "/vsts/agent/_work/1/s/eMeM.Tests/eMeM.Tests.csproj" (entry point):
2018-08-22T07:24:52.2998339Z                    Using "Coverlet.MSbuild.Tasks.CoverageResultTask" task from assembly "/root/.nuget/packages/coverlet.msbuild/2.2.1/build/netstandard2.0/coverlet.msbuild.tasks.dll".
2018-08-22T07:24:52.3015351Z                    Task "Coverlet.MSbuild.Tasks.CoverageResultTask" (TaskId:172)
2018-08-22T07:24:52.3032017Z                      Task Parameter:Output=/vsts/agent/_work/1/s/eMeM.Tests/ (TaskId:172)
2018-08-22T07:24:52.3048643Z                      Task Parameter:OutputFormat=cobertura (TaskId:172)
2018-08-22T07:24:52.3065096Z                      Task Parameter:Threshold=0 (TaskId:172)
2018-08-22T07:24:52.3081839Z                      Task Parameter:ThresholdType=line,branch,method (TaskId:172)
2018-08-22T07:24:52.3090313Z 
2018-08-22T07:24:52.3107632Z Calculating coverage result...
2018-08-22T07:24:52.3124707Z   Generating report '/vsts/agent/_work/1/s/eMeM.Tests/coverage.cobertura.xml'
2018-08-22T07:24:52.3143040Z 09:19:02.069   1:7>/root/.nuget/packages/coverlet.msbuild/2.2.1/build/netstandard2.0/coverlet.msbuild.targets(23,5): error : Index was out of range. Must be non-negative and less than the size of the collection. [/vsts/agent/_work/1/s/eMeM.Tests/eMeM.Tests.csproj]
2018-08-22T07:24:52.3161444Z /root/.nuget/packages/coverlet.msbuild/2.2.1/build/netstandard2.0/coverlet.msbuild.targets(23,5): error : Parameter name: index [/vsts/agent/_work/1/s/eMeM.Tests/eMeM.Tests.csproj]
2018-08-22T07:24:52.3178877Z                    Done executing task "Coverlet.MSbuild.Tasks.CoverageResultTask" -- FAILED. (TaskId:172)

I tracked it up to here https://www.fuget.org/packages/coverlet.msbuild/2.2.1/build/netstandard2.0/coverlet.msbuild.tasks.dll/Coverlet.MSbuild.Tasks/CoverageResultTask?code=true#M:Coverlet.MSbuild.Tasks.CoverageResultTask.Execute but I'm not sure where to find the relevant piece of code.

@tonerdo
Copy link
Collaborator

tonerdo commented Aug 22, 2018

Hi @j2ghz can you try this #135 (comment)

@j2ghz
Copy link
Author

j2ghz commented Aug 23, 2018

I tried it, still fails. I do have a working branch and a broken branch.
test csproj

@@ -2,16 +2,22 @@

   <PropertyGroup>
     <TargetFramework>netcoreapp2.1</TargetFramework>
-
+    <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
     <IsPackable>false</IsPackable>
   </PropertyGroup>

   <ItemGroup>
+    <PackageReference Include="AngleSharp" Version="0.9.10" />
-    <PackageReference Include="coverlet.msbuild" Version="2.1.1" />
+    <PackageReference Include="coverlet.msbuild" Version="2.2.1">
+      <PrivateAssets>all</PrivateAssets>
+      <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
+    </PackageReference>
     <PackageReference Include="FluentAssertions" Version="5.4.1" />
+    <PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="2.1.2" />
-    <PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="2.1.1" />
+    <PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="2.1.2" />
     <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
     <PackageReference Include="Moq" Version="4.9.0" />
+    <PackageReference Include="Moq.AutoMock" Version="1.2.0.111" />
     <PackageReference Include="xunit" Version="2.4.0" />
     <PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
     <DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />

main csproj

+    <LangVersion>7.3</LangVersion>
+    <DebugType>embedded</DebugType>
+    <DebugSymbols>true</DebugSymbols>

I have tried reverting coverlet version upgrade, but it didn't help. Other than that the difference between the branches is I have added some tests. If none of these changes seem suspicious to you I will start reverting one by one and see which one fixes it.

@j2ghz
Copy link
Author

j2ghz commented Aug 27, 2018

It was resolved by removing these lines from the main csproj:

+    <LangVersion>7.3</LangVersion>
+    <DebugType>embedded</DebugType>
+    <DebugSymbols>true</DebugSymbols>

@j2ghz j2ghz closed this as completed Aug 27, 2018
@csharpsi
Copy link

csharpsi commented Aug 30, 2018

I know this is closed, but for what it's worth, I was hitting this problem when setting up a new project build pipeline using an app that didn't yet have any implementation. I wanted to get the build pipeline including tests and coverage set up prior to starting work. Anyway, the reason I was getting this error was I hadn't yet referenced the app project from the test project. Adding the following to my test project csproj solved the problem.

<ItemGroup>
    <ProjectReference Include="..\..\App.csproj" />
</ItemGroup>

It's looking for assemblies with which to measure coverage against and not finding any (obvious now I think about it!). The error message could possibly be a bit clearer?

@vikasillumina
Copy link

vikasillumina commented Oct 5, 2018

I know this is closed, but for what it's worth, I was hitting this problem when setting up a new project build pipeline using an app that didn't yet have any implementation. I wanted to get the build pipeline including tests and coverage set up prior to starting work. Anyway, the reason I was getting this error was I hadn't yet referenced the app project from the test project. Adding the following to my test project csproj solved the problem.

<ItemGroup>
    <ProjectReference Include="..\..\App.csproj" />
</ItemGroup>

It's looking for assemblies with which to measure coverage against and not finding any (obvious now I think about it!). The error message could possibly be a bit clearer?

Thanks a bunch @csharpsi I had the same exact issue. I was trying to get my CI running and my unit test project just had a blank unit test and was not referencing any logic classes. Saw your message and added the references and it solved the issue.

Couldn't agree more the coverlet should handle this more. Between you and me it made at least 2 of us running into the same issue. @tonerdo any comments how we can make this better?

@MortenChristiansen
Copy link

MortenChristiansen commented Nov 16, 2018

I get the same error, but only after upgrading to version 2.3.1 of the coverlet.msbuild package. If I revert to 2.3.0, it works again. It appears to be related to the fact that 2 of my 3 test projects only have a single placeholder test. I do reference the projects under test, including a class from the projects, so the fix mentioned by @csharpsi does not work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants