Skip to content
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

[BUG]: PublishCodeCoverageResults@2 Error during reading file #19901

Closed
4 of 7 tasks
groogiam opened this issue May 22, 2024 · 4 comments
Closed
4 of 7 tasks

[BUG]: PublishCodeCoverageResults@2 Error during reading file #19901

groogiam opened this issue May 22, 2024 · 4 comments

Comments

@groogiam
Copy link

groogiam commented May 22, 2024

New issue checklist

Task name

PublishCodeCoverageResults@2

Task version

2.238.1

Issue Description

I recently installed the .NET 8 SDK on my build server and now this task no longer works. Please note my projects still Target .NET 7 and compile without issue. The DotNetCoreCLI@2 tests execution runs without issue as well.

Environment type (Please select at least one enviroment where you face this issue)

  • Self-Hosted
  • Microsoft Hosted
  • VMSS Pool
  • Container

Azure DevOps Server type

dev.azure.com (formerly visualstudio.com)

Azure DevOps Server Version (if applicable)

No response

Operation system

Windows 11

Relevant log output

2024-05-22T18:12:49: Error during reading file 'https://dev.azure.com/MyOrg/MyProject/_apis/git/repositories/my-repo/items?api-version=1.0&versionType=commit&version=sha1&path=/src/MyProject/MyFile.cs': Response status code does not indicate success: 500 (Internal Server Error).

Full task logs with system.debug enabled

 [REPLACE THIS WITH YOUR INFORMATION] 

Repro steps

- task: DotNetCoreCLI@2
    displayName: Unit Test Sandbox
    inputs:
      command: test
      projects: '**/*[Tt]ests/*.csproj'
      arguments: '--no-build --configuration ${{ parameters.buildConfiguration }} --settings src/MyProject.Tests/ci.runsettings --blame-hang-timeout 120s --blame-hang-dump-type full --blame-crash-dump-type full --filter IgnoreCi!=true${{ parameters.additionalTestFilters }}'
  
  - task: PublishCodeCoverageResults@2
    displayName: 'Publish Code Coverage Report'
    inputs:
      summaryFileLocation: '$(Agent.TempDirectory)/**/coverage.cobertura.xml'
@groogiam
Copy link
Author

I've compared the two files generated by the .NET 8 runtime and .NET 7 Runtime. For some reason the filename in the .NET 8 generated one is a url to devops not an actual file path.

.NET 7

<class name="MyProject.CopyRequest" filename="C:\agent\my-agent\_work\1\s\src\MyProject\CopyRequest.cs" line-rate="1" branch-rate="1" complexity="1">

.NET 8

<class name="MyProject.CopyRequest" filename="https://dev.azure.com/MyOrg/MyProject/_apis/git/repositories/my-repo/items?api-version=1.0&amp;versionType=commit&amp;version=CommitHash&amp;path=/src/MyProject/CopyRequest.cs" line-rate="1" branch-rate="1" complexity="1">

@groogiam
Copy link
Author

groogiam commented May 24, 2024

The link being output appears to be a result of using the SourceLink flag. However unsetting this flag does not seem to fix the issue it changes the filename to be a relative path MyProject\CopyRequest.cs in .NET 8 where as it is a fully qualified path in .NET 7. In either case it seems like this was changed in .NET 8 and this task does not account for the change. I'm not sure if this should be addressed by the publish task, the .NET sdk or coverlet?

<?xml version="1.0" encoding="utf-8" ?>
<RunSettings>
	<DataCollectionRunSettings>
		<DataCollectors>
			<DataCollector friendlyName="XPlat Code Coverage">
				<Configuration>
					<Format>cobertura,opencover</Format>
					<UseSourceLink>true</UseSourceLink>
					<SkipAutoProps>true</SkipAutoProps>
				</Configuration>
			</DataCollector>
		</DataCollectors>
	</DataCollectionRunSettings>
</RunSettings>

@groogiam
Copy link
Author

It looks like setting DeterministicReport true will revert the functionality to use a fully qualified path in .NET 8. However this flag is only supported by cobertura and not open cover. My particular configuration requires both as Sonar Cloud does not support cobetura. It really seems like this task needs to be updated to handle the path format change introduced via .NET 8 SDK.

@groogiam
Copy link
Author

I was able to to resolve this by just using the opencover format which is supported by PublishCodeCoverageResults@2 but not documented. The documentation page for this task https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/publish-code-coverage-results-v2?view=azure-pipelines does not appear to list what formats are supported.

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

No branches or pull requests

2 participants