Skip to content

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

Description

@mwiemer-microsoft

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:

<!-- Source (MyProject.resx) — relative path -->
<data name="Dictionary" type="System.Resources.ResXFileRef, System.Windows.Forms">
  <value>Dictionary.dic;System.String</value>
</data>
<!-- Generated (artifacts/obj/.../MyProject.xlf/MyProject.resx) — absolute path -->
<data name="Dictionary" type="System.Resources.ResXFileRef, System.Windows.Forms">
  <value>C:\Users\me\repos\myproject\src\MyProject\Dictionary.dic;System.String</value>
</data>

Suggested fix

Store the ResXFileRef path as a path relative to the translated .resx output file (i.e. the relative path from $(XlfIntermediateOutputPath)/.../<lang>/<ProjectName>.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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions