reqnroll / Reqnroll

Open-source Cucumber-style BDD test automation framework for .NET.
https://reqnroll.net
BSD 3-Clause "New" or "Revised" License
301 stars 32 forks source link

parallel build with multitarget : process cannot access the file #197

Open ZeChrales opened 3 days ago

ZeChrales commented 3 days ago

Reqnroll Version

2.0.3

Which test runner are you using?

NUnit

Test Runner Version Number

4.1.0

.NET Implementation

.NET 6.0

Test Execution Method

Azure DevOps Pipeline Task – PLEASE SPECIFY THE NAME OF THE TASK

Content of reqnroll.json configuration file

no json file

Issue Description

Hello, I'm trying to migrate specflow 3.9.74 to reqnroll 2.0.3, because we had an issue to build/test on azure pipelines. We are using azure task "dotnet build" / "dotnet test" and always get this kind of error : ##[error]C:\Users\Administrator\.nuget\packages\reqnroll.tools.msbuild.generation\2.0.3\build\Reqnroll.Tools.MsBuild.Generation.targets(93,5): Error : [Reqnroll] System.IO.IOException: The process cannot access the file 'C:\xxxxx.feature.cs' because it is being used by another process.

Our projects target net6.0;net48, and it seems it tries to create .feature.cs files in parallel for each target. I tested with Azure task "vstest" and it is the same behavior. Very rarely, it can also occurs in VS2022.

Steps to Reproduce

Link to Repro Project

No response

gasparnagy commented 2 days ago

I could not reproduce the file locks, but I see the problem. With a quick investigation I could not find an easy fix.

Would it be possible to apply a workaround of building the projects in two steps for the two target frameworks separately? Like:

dotnet build -f net6.0
dotnet build -f net48

I keep looking for a better solution in the meantime.

ZeChrales commented 1 day ago

Hello ! Yesterday we tried this workaround, but without real success. By looking at the dotnet build arguments, we found a working solution : dotnet build -m:1 dotnet test --no-build This removes parallelization so we don't have any build issue for now. And we kept tests running in parallel !

gasparnagy commented 1 day ago

@ZeChrales Thank you for finding & sharing this workaround!