Open tepatelcmc opened 1 year ago
Are you refering to #1155? The fix for this wasn't released yet, but it will be in the next release. You can try out the fix by consuming our nightly build (https://github.com/coverlet-coverage/coverlet/blob/master/Documentation/ConsumeNightlyBuild.md).
Don't think he means that one, but this one: https://github.com/coverlet-coverage/coverlet/issues/857
I'm facing this issue again when using coverlet.console v6.0.0 Since we didn't have the issue before my guess was a nugget, but it seems like it's actually the dotnet global tool (coverlet.console) which is causing the problem.
Just did some more testing with different versions of the tool: I don't have the issue using v3.1.x or v3.2.0, but I do with v6.0
With v6 I get this kind of exception:
---> System.IO.IOException: The process cannot access the file '(real path left out for nda reasons).pdb' because it is being used by another process.
at System.IO.FileSystem.CopyFile(String sourceFullPath, String destFullPath, Boolean overwrite)
at Coverlet.Core.Helpers.InstrumentationHelper.<>cDisplayClass17_0.1 action, Func
1 backoffStrategy, Int32 maxAttemptCount) in /_/src/coverlet.core/Helpers/RetryHelper.cs:line 55
I just started encountering this same after installing the newly-released C# Dev Kit for VSCode. It seems the processes started by VSCode keep a handle open on the assemblies:
TpTrace Warning: 0 : 20944, 1, 2023/06/07, 15:33:20.113, 4930720815067, datacollector.dll, [coverlet]Unable to instrument module: C:\Source\Personal\fourth-pharos\backend\FourthPharos.Domain.Tests\bin\Debug\net7.0\FourthPharos.Domain.dll
System.IO.IOException: The process cannot access the file 'C:\Source\Personal\fourth-pharos\backend\FourthPharos.Domain.Tests\bin\Debug\net7.0\FourthPharos.Domain.dll' because it is being used by another process.
at Microsoft.Win32.SafeHandles.SafeFileHandle.CreateFile(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options)
at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
at System.IO.Strategies.FileStreamHelpers.ChooseStrategyCore(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access)
at Coverlet.Core.Helpers.FileSystem.NewFileStream(String path, FileMode mode, FileAccess access) in /_/src/coverlet.core/Helpers/FileSystem.cs:line 52
at Coverlet.Core.Instrumentation.Instrumenter.InstrumentModule() in /_/src/coverlet.core/Instrumentation/Instrumenter.cs:line 207
at Coverlet.Core.Instrumentation.Instrumenter.Instrument() in /_/src/coverlet.core/Instrumentation/Instrumenter.cs:line 149
at Coverlet.Core.Coverage.PrepareModules() in /_/src/coverlet.core/Coverage.cs:line 135
Once I close VSCode and run dotnet test
again, instrumentation works as expected. Probably not much Coverlet can do about it, just wanted to mention it. I'll open an issue in the Dev Kit repo, once it goes public.
This issue is stale because it has been open for 3 months with no activity.
This has been a problem for my team as we have minimum code coverage being applied to changed code as a policy in pull requests. This bug is preventing us from being able to complete pull requests.
I have found that with this bug in 6.0.0, we get this error in the dotnet test
build log and 0% coverage reported for that project. I tried downgrading to 3.2.0. That version didn't throw the error but also reported 0% coverage. I have downgraded to 3.1.2 which:
This issue is stale because it has been open for 3 months with no activity.
Issue should be closed because the related coverlet nuget package is not mentioned and comments for all packages are available. The new issue template for bugs should improve this.
This issue is stale because it has been open for 3 months with no activity.
I get the same error on one of my .NET 4.8 projects.
I am using the coverlet console tool as part of an Azure Pipeline.
Tool version is 6.0.2
The exit code from coverlet is 255, which is undocumented.
Command:
coverlet C:\agents\A1\_work\64/RAT.IntTest.dll --target dotnet --targetargs test C:\agents\A1\_work\64/RAT.IntTest.dll --no-build --logger trx --diag:log.txt --format cobertura --source-mapping-file C:\agents\A1\_work\64/SourceMapping.txt --use-source-link --output C:\agents\A1\_work\64/coverage/coverage.cobertura.xml --verbosity detailed
Output:
(...)
BadImageFormatException during MetadataReaderProvider.FromPortablePdbStream in InstrumentationHelper.PortablePdbHasLocalSource, unable to check if module has got local source.
TryWithCustomResolverOnDotNetCore for PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Unable to instrument module: C:\agents\A1_work\64\RAT.exe
Coverlet.Core.Exceptions.CecilAssemblyResolutionException: AssemblyResolutionException for 'PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Try to add 3 read) at Mono.Cecil.ModuleWriter.BuildMetadata(ModuleDefinition module, MetadataBuilder metadata) at Mono.Cecil.ModuleWriter.Write(ModuleDefinition module, Disposable
1 stream, WriterParameters parameters)
at Mono.Cecil.ModuleWriter.WriteModule(ModuleDefinition module, Disposable`1 stream, WriterParameters parameters)
at Mono.Cecil.ModuleDefinition.Write(Stream stream, WriterParameters parameters)
at Coverlet.Core.Instrumentation.Instrumenter.InstrumentModule() in //src/coverlet.core/Instrumentation/Instrumenter.cs:line 325
at Coverlet.Core.Instrumentation.Instrumenter.Instrument() in //src/coverlet.core/Instrumentation/Instrumenter.cs:line 148
at Coverlet.Core.Coverage.PrepareModules() in /_/src/coverlet.core/Coverage.cs:line 135
One or more errors occurred. (The process cannot access the file 'C:\agents\A1_work\64\RAT.pdb' because it is being used by another process.) (The process cannot access the file 'C:\agents\A1_work\64\RAT.pdb' because it is being used by another process.) (The process cannot access the file 'C:\agents\A1_work\64\RAT.pdb' because it is being used by another process.) (The process cannot access the file 'C:\agents\A1_work\64\RAT.pdb' because it is being used by another process.) (The process cannot access the file 'C:\agents\A1_work\64\RAT.pdb' because it is being used by another process.) (The process cannot access the file 'C:\agents\A1_work\64\RAT.pdb' because it is being used by another process.) (The process cannot access the file 'C:\agents\A1_work\64\RAT.pdb' because it is being used by another process.) (The process cannot access the file 'C:\agents\A1_work\64\RAT.pdb' because it is being used by another process.) (The process cannot access the file 'C:\agents\A1_work\64\RAT.pdb' because it is being used by another process.) (The process cannot access the file 'C:\agents\A1_work\64\RAT.pdb' because it is being used by another process.) (The process cannot access the file 'C:\agents\A1_work\64\RAT.pdb' because it is being used by another process.) (The process cannot access the file 'C:\agents\A1_work\64\RAT.pdb' because it is being used by another process.)
Unhandled exception. System.AggregateException: One or more errors occurred. (The process cannot access the file 'C:\agents\A1_work\64\RAT.pdb' because it is being used by another process.) (The process cannot access the file 'C:\agents\A1_work\64\RAT.pdb' because it is being used by another process.) (The process cannot access the file 'C:\agents\A1_work\64\RAT.pdb' because it is being used by another process.) (The process cannot access the file 'C:\agents\A1_work\64\RAT.pdb' because it is being used by another process.) (The process cannot access the file 'C:\agents\A1_work\64\RAT.pdb' because it is being used by another process.) (The process cannot access the file 'C:\agents\A1_work\64\RAT.pdb' because it is being used by another process.) (The process cannot access the file 'C:\agents\A1_work\64\RAT.pdb' because it is being used by another process.) (The process cannot access the file 'C:\agents\A1_work\64\RAT.pdb' because it is being used by another process.) (The process cannot access the file 'C:\agents\A1_work\64\RAT.pdb' because it is being used by another process.) (The process cannot access the file 'C:\agents\A1_work\64\RAT.pdb' because it is being used by another process.) (The process cannot access the file 'C:\agents\A1_work\64\RAT.pdb' because it is being used by another process.) (The process cannot access the file 'C:\agents\A1_work\64\RAT.pdb' because it is being used by another process.)
---> System.IO.IOException: The process cannot access the file 'C:\agents\A1_work\64\RAT.pdb' because it is being used by another process.
BadImageFormatException during MetadataReaderProvider.FromPortablePdbStream in InstrumentationHelper.PortablePdbHasLocalSource, unable to check if module has got local source.
TryWithCustomResolverOnDotNetCore for PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Unable to instrument module: C:\agents\A1_work\64\RAT.exe
Coverlet.Core.Exceptions.CecilAssemblyResolutionException: AssemblyResolutionException for 'PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Try to add 3 read) at Mono.Cecil.ModuleWriter.BuildMetadata(ModuleDefinition module, MetadataBuilder metadata) at Mono.Cecil.ModuleWriter.Write(ModuleDefinition module, Disposable
1 stream, WriterParameters parameters)
at Mono.Cecil.ModuleWriter.WriteModule(ModuleDefinition module, Disposable`1 stream, WriterParameters parameters)
at Mono.Cecil.ModuleDefinition.Write(Stream stream, WriterParameters parameters)
at Coverlet.Core.Instrumentation.Instrumenter.InstrumentModule() in //src/coverlet.core/Instrumentation/Instrumenter.cs:line 325
at Coverlet.Core.Instrumentation.Instrumenter.Instrument() in //src/coverlet.core/Instrumentation/Instrumenter.cs:line 148
at Coverlet.Core.Coverage.PrepareModules() in /_/src/coverlet.core/Coverage.cs:line 135
One or more errors occurred. (The process cannot access the file 'C:\agents\A1_work\64\RAT.pdb' because it is being used by another process.) (The process cannot access the file 'C:\agents\A1_work\64\RAT.pdb' because it is being used by another process.) (The process cannot access the file 'C:\agents\A1_work\64\RAT.pdb' because it is being used by another process.) (The process cannot access the file 'C:\agents\A1_work\64\RAT.pdb' because it is being used by another process.) (The process cannot access the file 'C:\agents\A1_work\64\RAT.pdb' because it is being used by another process.) (The process cannot access the file 'C:\agents\A1_work\64\RAT.pdb' because it is being used by another process.) (The process cannot access the file 'C:\agents\A1_work\64\RAT.pdb' because it is being used by another process.) (The process cannot access the file 'C:\agents\A1_work\64\RAT.pdb' because it is being used by another process.) (The process cannot access the file 'C:\agents\A1_work\64\RAT.pdb' because it is being used by another process.) (The process cannot access the file 'C:\agents\A1_work\64\RAT.pdb' because it is being used by another process.) (The process cannot access the file 'C:\agents\A1_work\64\RAT.pdb' because it is being used by another process.) (The process cannot access the file 'C:\agents\A1_work\64\RAT.pdb' because it is being used by another process.)
Unhandled exception. System.AggregateException: One or more errors occurred. (The process cannot access the file 'C:\agents\A1_work\64\RAT.pdb' because it is being used by another process.) (The process cannot access the file 'C:\agents\A1_work\64\RAT.pdb' because it is being used by another process.) (The process cannot access the file 'C:\agents\A1_work\64\RAT.pdb' because it is being used by another process.) (The process cannot access the file 'C:\agents\A1_work\64\RAT.pdb' because it is being used by another process.) (The process cannot access the file 'C:\agents\A1_work\64\RAT.pdb' because it is being used by another process.) (The process cannot access the file 'C:\agents\A1_work\64\RAT.pdb' because it is being used by another process.) (The process cannot access the file 'C:\agents\A1_work\64\RAT.pdb' because it is being used by another process.) (The process cannot access the file 'C:\agents\A1_work\64\RAT.pdb' because it is being used by another process.) (The process cannot access the file 'C:\agents\A1_work\64\RAT.pdb' because it is being used by another process.) (The process cannot access the file 'C:\agents\A1_work\64\RAT.pdb' because it is being used by another process.) (The process cannot access the file 'C:\agents\A1_work\64\RAT.pdb' because it is being used by another process.) (The process cannot access the file 'C:\agents\A1_work\64\RAT.pdb' because it is being used by another process.)
---> System.IO.IOException: The process cannot access the file 'C:\agents\A1_work\64\RAT.pdb' because it is being used by another process.
We still have this issue on 6.0.0, 6.0.1 and 6.0.2. Version 3.2.0 still works fine.
We still have this issue on 6.0.0, 6.0.1 and 6.0.2. Version 3.2.0 still works fine.
Same here. v6.0.2 has the "because it is being used by another process." error but v3.2.0 works without issue.
I can see previous issue being fixed in an unofficial version - did it ever make it to stable release?
The issue still exist with running test in parallel with vstest code coverage (XPlat code coverage)