Skip to content

Bug: MSBuild file locking errors with Powertools 3.0.0 in large solutions with parallel builds #1038

@nCubed

Description

@nCubed

Expected Behaviour

Building a large solution (80+ projects) with AWS.Lambda.Powertools.Logging 3.0.0 should complete successfully with parallel builds enabled.

Current Behaviour

MSBuild fails with file locking errors when multiple projects reference a common assembly that depends on Powertools 3.0.0:

warning MSB3061: Unable to delete file "...<project>\bin\Debug\net8.0<project>.dll". The process cannot access the file because it is being used by another process. The file is locked by: "MSBuild.exe (21664), MSBuild.exe (17708), MSBuild.exe (11540)..."

The issue occurs with both Visual Studio and CLI builds (dotnet build).

Root Cause

Powertools 3.0.0 upgraded AspectInjector from 2.8.1 to 2.9.0. AspectInjector 2.9.0 https://github.com/pamidur/aspect-injector/releases/tag/2.9.0, which appears to cause file locking issues when processing assemblies in parallel build scenarios.

Code snippet

**<project>.csproj** (shared assembly referenced by 70+ projects):

<ItemGroup>
<PackageReference Include="AWS.Lambda.Powertools.Logging" Version="3.0.0" />
<!-- other dependencies -->
</ItemGroup>

Possible Solution

No response

Steps to Reproduce

  1. Create a large solution with a common shared library referenced by many projects
  2. Add AWS.Lambda.Powertools.Logging version 3.0.0 to the shared library
  3. Build the solution with parallel builds enabled (default)
  4. Observe MSBuild file locking errors on the shared library assembly

Note: The issue does NOT occur with Powertools 2.0.2 (AspectInjector 2.8.1) in the same solution.

Powertools for AWS Lambda (.NET) version

3.0.0

AWS Lambda function runtime

dotnet8

Debugging logs

Metadata

Metadata

Assignees

Labels

bugUnexpected, reproducible and unintended software behaviourreleasedFix or implementation already in main and released

Type

No type

Projects

Status

✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions