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

Unable to disable determistic source mapping in Microsoft.CodeCoverage #5178

Closed
Nico-1987 opened this issue Aug 14, 2024 · 3 comments · Fixed by #5189
Closed

Unable to disable determistic source mapping in Microsoft.CodeCoverage #5178

Nico-1987 opened this issue Aug 14, 2024 · 3 comments · Fixed by #5189

Comments

@Nico-1987
Copy link

Nico-1987 commented Aug 14, 2024

Description

After upgrading our build tools to 17.10, we started seeing .msCoverageSourceRootsMapping_testassembly files in a subfolder of our output folder.
We managed to trace these files back to the Microsoft.CodeCoverage package, where the MsCoverageReferencedPathMaps target was introduced.
#4849

This target always runs when build, it does not allow the user to disable it.

  1. Why are these files needed during the build if code coverage is not required? I don't want them if they are not needed.
  2. The location where the files are stored cannot be controlled. In our environment, the files appear in a strange location "bin\debug\net6.0-windows10.0.19041\net6.0-windows10.0.19041\win-x64", while the test assembly itself is in "bin\debug\net6.0-windows10.0.19041". Not sure why the files end up in the wrong subfolder... looking at the code it should be using $(OutputPath). It would be good to add the option to override this path.
  3. Nowhere in the (normal verbosity) build logs i could these files being generated.
  4. We dont even use the Microsoft.CodeCoverage NuGet package. Which package pulls this in?

Steps to reproduce

Create a class library and a unit test project with a test. Build the projects and notice the .msCoverageSourceRootsMapping_TestProject2 being generated in the output folder.

Expected behavior

  1. I expect properties are available that allow me to disable this functionality
  2. I expect i have the option to set a property to override the rootPath used to write these files
  3. I expect the tasks have some output to the log files
  4. I dont even expect the Microsoft.CodeCoverage NuGet package to be used, it is not visible in my Visual Studio solution explorer

Actual behavior

Undesired files are written and i have no way to monitor and control this.

Environment

We have multiple .NET projects using

  • Visual Studio 2022 LTSC 17.10

  • .NET 6 SDK 6.0.424

  • Relevant packageReferences

      <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
      <PackageReference Include="MSTest.TestAdapter" Version="2.2.10" />
      <PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
    

image

@nohwnd
Copy link
Member

nohwnd commented Aug 15, 2024

@fhnaseer please have a look.

@fhnaseer
Copy link
Member

fhnaseer commented Aug 16, 2024

Microsoft.CodeCoverage is added as a dependency of Microsoft.NET.Test.Sdk. @jakubch1 can you please have a look into this?

@Nico-1987
Copy link
Author

@fhnaseer, thank you for fixing our biggest problem with this target.
While making changes, may i suggest you add an option to overwrite/correct the targetdir as well?

As i mentioned in point 2, in our case the files do not end up next to the assembly, but 2 levels deeper, something clearly is going wrong there. For us it would work if we can override the root dir that is used in the _msCoverageSourceRootMappingFilePath property.

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

Successfully merging a pull request may close this issue.

3 participants