dotnet / dotnet/arcade

TranslateSource bakes absolute ResXFileRef paths into cached translated .resx files, breaking incremental builds after repo rename/move (MSB3103)

Open
#17,061 0 comments 0 reactions 1 assignee Claimed by @mmitche View on GitHub
Dominant language
C#
Stars
729
Forks
397
Avg merge
3d 15m
Merged PRs (30d)
149

Description

Minimal reproduction: https://github.com/mwiemer-microsoft/xliff-tasks-issue-842/tree/c08a6970493aa4d3a48aafd768b19f91ce81a259

1. Build any repo using `.resx` and `ResXFileRef` (including dotnet/roslyn)
2. Rename your clone of the repo
3. Build again

Expected: just works

Actual: Fails:

```
error MSB3103: Invalid Resx file. Could not find a part of the path
'C:\old-location-that-no-longer-exists\icon.bin'. [Repro.csproj]
```

## Suspected root cause

When XliffTasks translates a `.resx` file that contains `ResXFileRef` entries with **relative** paths (e.g. `Dictionary.dic`), the generated translated `.resx` placed in the intermediate output directory (e.g. `artifacts/obj/.../MyProject.xlf/MyProject.resx`) receives **absolute** paths instead:

```xml

Dictionary.dic;System.String

```

```xml

C:\Users\me\repos\myproject\src\MyProject\Dictionary.dic;System.String

```

## Suggested fix

Store the ResXFileRef path as a path relative to the translated .resx output file (i.e. the relative path from `$(XlfIntermediateOutputPath)/...//.resx` back to the original resource file)

## Environment

XliffTasks version: 10.0.0-beta.26304.4 (also reproduced on older versions)
MSBuild / dotnet: desktop MSBuild 17.x (Build.cmd) and dotnet build (SDK 10.x)
OS: Windows

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.