Skip to content

Exception: The process cannot access file because it is being used by another process #997

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

Closed
xJom opened this issue Nov 23, 2020 · 3 comments
Labels
waiting for customer Waiting for customer action

Comments

@xJom
Copy link

xJom commented Nov 23, 2020

Running a test, where UUT has an explicit dependency to an Interface-dll, and the test has an implicit dependency to the same Interface-dll, the data collector cannot access this dll, after calculating coverage.

I have tried the 1.2.0 as well as the latest 3.0.0-preview.9 (for both coverlet.msbuild and coverlet.collector).

The command I run has been enhanced with all previous tips in #857 :
dotnet test /nodeReuse:false -m:1 .\XUnit.Coverlet.Collector.csproj /p:ParallelizeTestCollections=false /p:CopyLocalLockFileAssemblies=true /p:ExcludeFromCodeCoverage=MessageFormatInterface --collect:"XPlat Code Coverage"

The inner exception is repeated 9 times, so I only report the last here: 18:12:35 ---> (Inner Exception #9) System.IO.IOException: The process cannot access the file 'C:\Jenkins\workspace\SharedUI\SharedUI-develop_builder\UnitTests\XUnit.Coverlet.Collector\bin\Debug\netcoreapp3.1\MessageFormatInterface.dll' because it is being used by another process. 18:12:35 at System.IO.FileSystem.CopyFile(String sourceFullPath, String destFullPath, Boolean overwrite) 18:12:35 at System.IO.File.Copy(String sourceFileName, String destFileName, Boolean overwrite) 18:12:35 at Coverlet.Core.Helpers.FileSystem.Copy(String sourceFileName, String destFileName, Boolean overwrite) in D:\git\coverletToRelease\src\coverlet.core\Helpers\FileSystem.cs:line 33 18:12:35 at Coverlet.Core.Helpers.InstrumentationHelper.<>c__DisplayClass9_0.<RestoreOriginalModule>b__0() in D:\git\coverletToRelease\src\coverlet.core\Helpers\InstrumentationHelper.cs:line 214 18:12:35 at Coverlet.Core.Helpers.RetryHelper.<>c__DisplayClass0_0.<Retry>b__0() in D:\git\coverletToRelease\src\coverlet.core\Helpers\RetryHelper.cs:line 26 18:12:35 at Coverlet.Core.Helpers.RetryHelper.Do[T](Func1 action, Func1 backoffStrategy, Int32 maxAttemptCount) in D:\git\coverletToRelease\src\coverlet.core\Helpers\RetryHelper.cs:line 52<--- 18:12:35 18:12:35 --- End of inner exception stack trace --- 18:12:35 at Coverlet.Collector.DataCollection.CoverageManager.InstrumentModules() in D:\git\coverletToRelease\src\coverlet.collector\DataCollection\CoverageManager.cs:line 68 18:12:35 at Coverlet.Collector.DataCollection.CoverletCoverageCollector.OnSessionStart(Object sender, SessionStartEventArgs sessionStartEventArgs) in D:\git\coverletToRelease\src\coverlet.collector\DataCollection\CoverletCoverageCollector.cs:line 127.

@MarcoRossignoli MarcoRossignoli added the waiting for customer Waiting for customer action label Nov 26, 2020
@MarcoRossignoli
Copy link
Collaborator

MarcoRossignoli commented Nov 26, 2020

To filter out that asm you need to use a runsetting file for collectors, take a look at guide

https://github.com/coverlet-coverage/coverlet/blob/master/Documentation/VSTestIntegration.md#advanced-options-supported-via-runsettings

<?xml version="1.0" encoding="utf-8" ?>
<RunSettings>
  <DataCollectionRunSettings>
    <DataCollectors>
      <DataCollector friendlyName="XPlat code coverage">
        <Configuration>
          <Format>cobertura</Format>          
          <Exclude>[MessageFormatInterface]*</Exclude>
        </Configuration>
      </DataCollector>
    </DataCollectors>
  </DataCollectionRunSettings>
</RunSettings>

Please enable also the logging so we can take a look at filtered dll https://github.com/coverlet-coverage/coverlet/blob/master/Documentation/Troubleshooting.md#collectors-integration

@xJom
Copy link
Author

xJom commented Nov 26, 2020

Yes!
That worked. (And it works with 2.9.1 and 3.0.0-preview.9 both.)
Thank you very much.

@xJom xJom closed this as completed Nov 26, 2020
@MarcoRossignoli
Copy link
Collaborator

Glad to hear that!

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

No branches or pull requests

2 participants