microsoft / codecoverage

MIT License
73 stars 12 forks source link

[Question] Microsoft.CodeCoverage expected behavior with MSBuild /p:CreateHardLinksForCopyLocalIfPossible=true #118

Closed Cjewett closed 3 months ago

Cjewett commented 3 months ago

I also posted this question in Coverlet (https://github.com/coverlet-coverage/coverlet/issues/1651) because our company currently uses both Coverlet and Microsoft.CodeCoverage. There is a desire to turn on CreateHardLinksForCopyLocalIfPossible to reduce the size of our build output because we're running out of storage. When using Coverlet it hits System.IO.Exception TestProject.dll cannot be accessed because it is being used by another process. That is expected considering how code coverage normally works due to instrumentation, but I'm hoping this case has been handled in the official Microsoft solution. A couple questions:

jakubch1 commented 3 months ago

Microsoft.CodeCoverage supports dynamic instrumentation which will work the best in this scenario: https://github.com/microsoft/codecoverage/blob/main/docs/instrumentation.md#static-and-dynamic-instrumentation Dynamic instrumentation is not modifying files on disk so parallel run should be possible.

Static instrumentation is enabled by default on non-Windows envs. Add <EnableStaticManagedInstrumentation>True</EnableStaticManagedInstrumentation> to your config to disable it.

Cjewett commented 3 months ago

Thanks for the quick reply @jakubch1 !