aspnetcore: 'The process cannot access the file' during CI build sometimes

This has been happening a few times recently. It’s odd because BlazorTemplates.Tests doesn’t depend on Microsoft.DotNet.Web.Spa.ProjectTemplates so it shouldn’t be copying it anywhere.

There is some custom msbuild logic being invoked right before the error: https://github.com/dotnet/aspnetcore/blob/main/src/ProjectTemplates/TestInfrastructure/PrepareForTest.targets So maybe that has something to do with it. We might just need to add /bl to this part of the build temporarily.

Example build: https://dev.azure.com/dnceng/public/_build/results?buildId=1106179&view=logs&j=48c285a2-daf4-5ecb-cb99-42232769ca29&t=73646f8d-7520-5361-e1ad-d9d207b2cd21

./src/ProjectTemplates/build.sh --ci --nobl --pack --no-restore --no-build-deps
========================== Starting Command Output ===========================
/bin/bash --noprofile --norc /datadisks/disk1/workspace/_work/_temp/7404866d-8c11-4324-8bfe-b62b36813c80.sh
  RepoTasks -> /datadisks/disk1/workspace/_work/1/s/artifacts/bin/RepoTasks/Release/net6.0/RepoTasks.dll
  Successfully created package '/datadisks/disk1/workspace/_work/1/s/artifacts/packages/Release/Shipping/Microsoft.DotNet.Web.Client.ItemTemplates.6.0.0-ci.nupkg'.
  Successfully created package '/datadisks/disk1/workspace/_work/1/s/artifacts/packages/Release/Shipping/Microsoft.DotNet.Web.ItemTemplates.6.0.0-ci.nupkg'.
  Preparing environment for tests
  Removed directory /datadisks/disk1/workspace/_work/1/s/src/ProjectTemplates/BlazorTemplates.Tests/bin/Release/net6.0/TestTemplates/
  Removed directory /datadisks/disk1/workspace/_work/1/s/obj/template-restore/
  Created directory /datadisks/disk1/workspace/_work/1/s/src/ProjectTemplates/BlazorTemplates.Tests/bin/Release/net6.0/TestTemplates/
  Created directory /datadisks/disk1/workspace/_work/1/s/obj/template-restore/
  Successfully created package '/datadisks/disk1/workspace/_work/1/s/artifacts/packages/Release/Shipping/Microsoft.DotNet.Web.ProjectTemplates.6.0.6.0.0-ci.nupkg'.
/datadisks/disk1/workspace/_work/1/s/.dotnet/sdk/6.0.100-preview.4.21222.6/Microsoft.Common.CurrentVersion.targets(4965,5): error MSB3026: Could not copy "/datadisks/disk1/workspace/_work/1/s/artifacts/packages/Release/Shipping/Microsoft.DotNet.Web.Spa.ProjectTemplates.6.0.6.0.0-ci.nupkg" to "bin/Release/net6.0/Microsoft.DotNet.Web.Spa.ProjectTemplates.6.0.6.0.0-ci.nupkg". Beginning retry 1 in 1000ms. The process cannot access the file '/datadisks/disk1/workspace/_work/1/s/artifacts/packages/Release/Shipping/Microsoft.DotNet.Web.Spa.ProjectTemplates.6.0.6.0.0-ci.nupkg' because it is being used by another process.  [/datadisks/disk1/workspace/_work/1/s/src/ProjectTemplates/BlazorTemplates.Tests/BlazorTemplates.Tests.csproj]
##[error].dotnet/sdk/6.0.100-preview.4.21222.6/Microsoft.Common.CurrentVersion.targets(4965,5): error MSB3026: (NETCORE_ENGINEERING_TELEMETRY=Build) Could not copy "/datadisks/disk1/workspace/_work/1/s/artifacts/packages/Release/Shipping/Microsoft.DotNet.Web.Spa.ProjectTemplates.6.0.6.0.0-ci.nupkg" to "bin/Release/net6.0/Microsoft.DotNet.Web.Spa.ProjectTemplates.6.0.6.0.0-ci.nupkg". Beginning retry 1 in 1000ms. The process cannot access the file '/datadisks/disk1/workspace/_work/1/s/artifacts/packages/Release/Shipping/Microsoft.DotNet.Web.Spa.ProjectTemplates.6.0.6.0.0-ci.nupkg' because it is being used by another process. 
  Successfully created package '/datadisks/disk1/workspace/_work/1/s/artifacts/packages/Release/Shipping/Microsoft.DotNet.Web.Spa.ProjectTemplates.6.0.6.0.0-ci.nupkg'.
  Preparing environment for tests
  Removed directory /datadisks/disk1/workspace/_work/1/s/src/ProjectTemplates/test/bin/Release/net6.0/TestTemplates/
  Removed directory /datadisks/disk1/workspace/_work/1/s/obj/template-restore/
  Created directory /datadisks/disk1/workspace/_work/1/s/src/ProjectTemplates/test/bin/Release/net6.0/TestTemplates/
  Created directory /datadisks/disk1/workspace/_work/1/s/obj/template-restore/
  BlazorTemplates.Tests -> /datadisks/disk1/workspace/_work/1/s/src/ProjectTemplates/BlazorTemplates.Tests/bin/Release/net6.0/BlazorTemplates.Tests.dll
  ProjectTemplates.Tests -> /datadisks/disk1/workspace/_work/1/s/src/ProjectTemplates/test/bin/Release/net6.0/ProjectTemplates.Tests.dll

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 36 (32 by maintainers)

Most upvoted comments

I suggest examining a binary log and trying to determine what else is accessing the file. We don’t use mono-based runtimes ourselves and unfortunately can’t help directly.

Ah, rerun overwrote the _Logs artifact 😦 I got the dumps from the Windows_Test_Dumps artifact. Went looking there because we capture dotnet dumps now and the process didn’t exit normally according to the console logs for the first attempt.

Might be interesting to include the attempt number in some of the artifact names❔