Skip to content

@nx/dotnet: Remote cache restoration fails across CI agents due to absolute paths in .NET obj/ artifacts #33684

Description

@jvskriubakken

Current Behavior

Description:
When using @nx/dotnet with remote caching across different CI agents, builds fail because .NET's obj/ directory contains hardcoded absolute paths that don't get rewritten during cache restoration.

Actual behaviour:

Builds fail when cache is restored on a different agent because absolute paths in obj/ artifacts don't match the new agent's paths.

Environment:

Nx version: 22.1.3
@nx/dotnet version: 22.1.3
Node version: 22.18.0
OS: Windows (multiple CI agents)
CI: Azure Pipelines with multiple build agents
Nx Cloud: Enabled
Root Cause: .NET build artifacts in the obj/ directory contain absolute paths (e.g., in project.assets.json, *.csproj.nuget.g.props, and the ref/ subdirectory). When these artifacts are cached and restored on a different CI agent with a different working directory, the paths no longer match, causing build failures.

Evidence from CI Log:

# Cache hit from Agent 1 (AirmontBuildAgent)
> nx run shared-cs-time:"build:release"  [remote cache]
  Shared.Time -> C:\AirmontBuildAgent\_work\11\s\libs\shared\cs\Shared.Time\bin\Release\net8.0\Shared.Time.dll

# Build failure on Agent 2 (BuildAgent) - different path!
> nx run firefly-shared-cs-core:build
CSC : error CS0006: Metadata file 'C:\BuildAgent\_work\10\s\libs\shared\cs\Shared.Time\obj\Debug\net8.0\ref\Shared.Time.dll' could not be found

Expected Behavior

Remote cache should work across different CI agents regardless of their working directory paths.

GitHub Repo

No response

Steps to Reproduce

Nx Report

Node           : 22.18.0
OS             : darwin-arm64
Native Target  : aarch64-macos
pnpm           : 10.17.0

nx (global)        : 22.1.2
nx                 : 22.1.3
@nx/js             : 22.1.3
@nx/eslint         : 22.1.3
@nx/workspace      : 22.1.3
@nx/devkit         : 22.1.3
@nx/dotnet         : 22.1.3
@nx/eslint-plugin  : 22.1.3
@nx/gradle         : 22.1.3
@nx/playwright     : 22.1.3
@nx/plugin         : 22.1.3
@nx/react          : 22.1.3
@nx/storybook      : 22.1.3
@nx/vite           : 22.1.3
@nx/web            : 22.1.3
typescript         : 5.9.2
---------------------------------------
Registered Plugins:
nx-tools-azure
nx-tools-chimney-insights
nx-tools-i18next
nx-tools-dotnet
nx-tools-sentry
@nx/eslint/plugin
@nx/dotnet
@nx/storybook/plugin
@nx/vite/plugin
@nx/playwright/plugin
---------------------------------------
Local workspace plugins:
nx-tools-chimney-insights
nx-tools-i18next
nx-tools-dotnet
nx-tools-sentry
nx-tools-azure
---------------------------------------
Cache Usage: 2.70 MB / 92.64 GB

Failure Logs

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

Metadata

Metadata

Assignees

Labels

outdatedpriority: highHigh Priority (important issues which affect many people severely)scope: dotnetIssues related to .NETtype: bug

Type

Fields

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions