nx-dotnet: [BUG] Concurrency errors when accessing same files as parallel test
Current Behavior
When testing 2 projects targeting the same file, we get a CS1202 The process cannot access the file '' because it is being used by another process. These are caused by 3 items:
- a
runtimeconfig.json' - a
.deps.json - a
.dllfile
All the .net standard and .net 6 projects have RestorePackagesWithLockFile on them
<PropertyGroup>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>
this is the dependency graph
Expected Behavior
That the nx affected --target test runs and does not lock the file, therefore running the dotnet projects parallel
Github Repo
No response
Steps to Reproduce
- Have 3 dotnet items(projects/libs) with test projects, where 1 project is being used by 2 test projects
- (don’t know if this is affecting it) Have package restore on them
- run the tests
Nx Report
> NX Report complete - copy this into the issue template
Node : 20.3.0
OS : win32 x64
npm : 9.6.4
Hasher : Native
nx : 16.0.3
@nx/js : 16.0.3
@nx/jest : 16.0.3
@nx/linter : 16.0.3
@nx/workspace : 16.0.3
@nx/angular : 16.0.3
@nx/cypress : 16.0.3
@nx/devkit : 16.0.3
@nx/eslint-plugin : 16.0.3
@nx/plugin : 16.0.3
@nrwl/tao : 16.0.3
@nx/webpack : 16.0.3
nx-cloud : 16.0.5
typescript : 4.9.5
---------------------------------------
Community plugins:
@fortawesome/angular-fontawesome : 0.12.1
@ngrx/component-store : 15.4.0
@ngrx/component : 15.4.0
@ngrx/effects : 15.4.0
@ngrx/entity : 15.4.0
@ngrx/router-store : 15.4.0
@ngrx/store-devtools : 15.4.0
@ngrx/store : 15.4.0
@ngrx/schematics : 15.4.0
@nx-dotnet/core : 1.22.0
---------------------------------------
Local workspace plugins:
@meteninbim/workspace-plugin
nx.json
{
"npmScope": "meteninbim",
"affected": {
"defaultBase": "master"
},
"tasksRunnerOptions": {
"default": {
"runner": "nx-cloud",
"options": {
"cacheableOperations": ["build", "lint", "test", "e2e"],
"parallel": 3
}
}
},
"plugins": ["@nx-dotnet/core"],
"generators": {
"@nx/angular:application": {
"style": "scss",
"linter": "eslint",
"unitTestRunner": "jest",
"e2eTestRunner": "cypress"
},
"@nx/angular:library": {
"linter": "eslint",
"unitTestRunner": "jest"
},
"@schematics/angular:component": {
"style": "scss",
"changeDetection": "OnPush",
"project": "client",
"path": "apps/client/src/app"
},
"@nx/angular:component": {
"style": "scss",
"changeDetection": "OnPush",
"project": "client",
"path": "apps/client/src/app"
}
},
"$schema": "./node_modules/nx/schemas/nx-schema.json",
"cli": {
"cache": {
"enabled": true
}
},
"targetDefaults": {
"build": {
"dependsOn": ["^build"],
"inputs": ["production", "^production"]
},
"test": {
"inputs": [
"default",
"^production",
"{workspaceRoot}/jest.preset.js"
]
},
"lint": {
"inputs": ["default", "{workspaceRoot}/.eslintrc.json"]
},
"lint-fix": {
"inputs": ["default", "{workspaceRoot}/.eslintrc.json"]
},
"serve": {
"dependsOn": ["^build"]
}
},
"namedInputs": {
"default": ["{projectRoot}/**/*", "sharedGlobals"],
"sharedGlobals": [],
"production": [
"default",
"!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)",
"!{projectRoot}/tsconfig.spec.json",
"!{projectRoot}/jest.config.[jt]s",
"!{projectRoot}/.eslintrc.json"
]
}
}
Failure Logs
Executing Command: dotnet "test" "C:\Source\repos\DigitaalMeten\3d\meteninbim\apps\api-integration-test\Meteninbim.Api.IntegrationTest.csproj" "--settings" "../../csharp.runsettings" "--results-directory" "../../coverage/apps/api-integration-test"
Determining projects to restore...
Restored C:\Source\repos\DigitaalMeten\3d\meteninbim\apps\api\Meteninbim.Api.csproj (in 724 ms).
7 of 8 projects are up-to-date for restore.
Meteninbim.Bimsync -> C:\Source\repos\DigitaalMeten\3d\meteninbim\dist\libs\bimsync\netstandard2.0\Meteninbim.Bimsync.dll
Meteninbim.Common -> C:\Source\repos\DigitaalMeten\3d\meteninbim\dist\libs\shared\MeteninBim.Common\netstandard2.0\Meteninbim.Common.dll
CSC : error CS2012: Cannot open 'C:\Source\repos\DigitaalMeten\3d\meteninbim\libs\business\obj\Debug\net6.0\Meteninbim.Business.dll' for writing -- 'The process cannot access the file 'C:\Source\repos\DigitaalMeten\3d\meteninbim\libs\business\obj\Debug\net6.0\Meteninbim.Business.dll' because it is being used by another process.' [C:\Source\repos\DigitaalMeten\3d\meteninbim\libs\business\Meteninbim.Business.csproj]
Meteninbim.Shared.Startup -> C:\Source\repos\DigitaalMeten\3d\meteninbim\dist\libs\shared\startup\net6.0\Meteninbim.Shared.Startup.dll
Error: dotnet execution returned status code 1
at DotNetClient.logAndExecute (C:\Source\repos\DigitaalMeten\3d\meteninbim\node_modules\@nx-dotnet\dotnet\src\lib\core\dotnet.client.js:171:19)
at DotNetClient.test (C:\Source\repos\DigitaalMeten\3d\meteninbim\node_modules\@nx-dotnet\dotnet\src\lib\core\dotnet.client.js:78:25)
at C:\Source\repos\DigitaalMeten\3d\meteninbim\node_modules\@nx-dotnet\core\src\executors\test\executor.js:17:41
at Generator.next (<anonymous>)
at fulfilled (C:\Source\repos\DigitaalMeten\3d\meteninbim\node_modules\tslib\tslib.js:164:62)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Additional Information
i tried removing RestorePackagesWithLockFile, but this still showed the same error
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 5
- Comments: 21 (10 by maintainers)
This is interesting… I’ll look into it, may be locking happening on the .NET side of things. We don’t really touch those files so I’ll have to see if its something we can get around.
Set noBuild true for the test target, no dependencies true for the build target, and test to depend on build, and build to depend on dependant project builds