question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Index was out of range. VSTS

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6

github_iconTop GitHub Comments

2reactions
csharpsicommented, 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?

0reactions
MortenChristiansencommented, 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Index Out of Range exception visual studio
If you are getting an index out of range, it tends to mean you are accessing an array with a number greater than...
Read more >
Index was out of range. Must be non-negative and less ...
Opened installer from VS Tools -> Get Tools and Features..., allowed Elevation, and this error occurred in the installer. Fixed In: Visual ......
Read more >
Index was out of range. Must be non-negative and less ...
Index was out of range. Must be non-negative and less than the size of the collection.Parameter name: indexClosed - Duplicate0 3.
Read more >
KB2850388 - FIX: "Index was out of range" error message ...
Fixes an issue in which SSAS 2012 crashes when you use SSDT - Business Intelligence for Visual Studio 2012 to create a perspective....
Read more >
[Solved] Index out of range error
i want to get the average mark for all quizzes but it show index out of range error. Why? Same calculation method i...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found