csproj export emits embedded resources flat instead of restoring folder structure from dotted LogicalName
维护者通常 1 天内回复
还没有人认领这个 Issue。
- #3735 来自 @OpenSourcereR-dev —— 已关闭,未合并
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 58/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 技术栈
- csharp
- 领域
- build-system, cli, tooling
调研方向
从 ilspycmd 的项目导出入口开始,使用 ilspycmd MyApp.exe -p -o ./out 重现该问题。跟踪 EmbeddedResource 项及其 LogicalName 值如何变成文件和 csproj 条目。完成标准是:带点的资源名称会映射到预期的文件夹,同时 LogicalName 保持不变,包括文档中记录的前导下划线和带点文件夹案例。
由索引模型根据 Issue 内容生成。
描述
Summary
When exporting an assembly as a .csproj (ilspycmd <asm> -p), embedded
resources are written to disk as flat files in the project root with their
full dotted manifest names as the filenames, rather than being restored to a
folder hierarchy that matches what the original source tree probably looked
like. The dotted segments of the resource name encode exactly that hierarchy
(modulo SDK name-mangling rules).
Steps to reproduce
Take any assembly built from a project whose source tree organizes assets
into folders (e.g. images/CopyHS.png, payloads/9.01/payloadName.bin), then:
ilspycmd MyApp.exe -p -o ./out
Actual output
out/
├── MyApp.images.CopyHS.png
├── MyApp.images.CutHS.png
├── MyApp.images.donate_full.png
├── MyApp.payloads._9._01.payloadName.bin
└── MyApp.csproj
with corresponding csproj entries:
<None Remove="MyApp.images.CopyHS.png" />
<EmbeddedResource Include="MyApp.images.CopyHS.png"
LogicalName="MyApp.images.CopyHS.png" />
Expected output
out/
├── images/
│ ├── CopyHS.png
│ ├── CutHS.png
│ └── donate_full.png
├── payloads/
│ └── 9.01/
│ └── payloadName.bin
└── MyApp.csproj
with csproj entries that preserve the original logical name even though the
file now lives in a folder, so existing
Assembly.GetManifestResourceStream("MyApp.images.CopyHS.png") calls in the
decompiled code keep working unchanged:
<EmbeddedResource Include="images\CopyHS.png"
LogicalName="MyApp.images.CopyHS.png" />
Why this matters
Right now, opening the decompiled csproj in Visual Studio shows a project
root with dozens of dotted-name files all jumbled together at the top level.
Reorganizing them into the original folder layout is a purely mechanical
transform (the dot-separated logical name is the encoding of the original
path) but currently has to be done by hand for every decompiled project.
Proposed approach
For each EmbeddedResource whose logical name begins with the project's
root namespace (typically the assembly name), strip that prefix, split the
remainder on ., treat the last segment as the file extension, the
second-to-last as the filename stem, and the rest as folder segments.
Apply the inverse of the SDK's leading-_ mangling for segments that begin
with _<digit>. Preserve the original LogicalName= attribute on the
emitted item so the resource keys stay byte-identical and existing
reflection-based resource lookups in the decompiled code keep working.
There is one inherent ambiguity (a folder name like 9.01 round-trips to
_9._01 which is indistinguishable from a 9/01/ two-folder hierarchy
without external knowledge), but a heuristic that merges consecutive
underscore-digit segments into a single dotted folder name handles the
common case and is no worse than the current behavior for the others.
Details
- Product in use: ilspycmd
- Version in use: 10.0.0.8330 (latest stable as of 2026-04-13)
- 主要语言
- C#
- 星标
- 27.1k
- 派生
- 3.8k
- 平均合并
- 1 天 23 小时
- 30 天内合并 PR
- 44
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
icsharpcode/ILSpy 的其他 Issue
-
External UI
难度 1/5 1-3 小时 新手友好度 75/100
icsharpcode/ILSpy#4284 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 55/100
icsharpcode/ILSpy#4357 ·
维护者通常 1 天内回复
-
Misdecompilation of a lazy initialization pattern可能已有人在做 @siegfriedpammer 于 5 天前认领。 未关闭Bug Decompiler
难度 4/5 3-5 天 新手友好度 20/100
icsharpcode/ILSpy#4349 ·
维护者通常 1 天内回复
-
Bug
难度 4/5 3-5 天 新手友好度 45/100
icsharpcode/ILSpy#4343 ·
维护者通常 1 天内回复
-
AI
难度 4/5 1-2 天 新手友好度 55/100
icsharpcode/ILSpy#4300 ·
维护者通常 1 天内回复
查看 icsharpcode/ILSpy 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
umbraco/Umbraco.Automate#612 ·
维护者通常 1 天内回复
-
崩溃日志只按 CRLF 分行未关闭
难度 2/5 1-3 小时 新手友好度 72/100
PCL-Community/PCL-CE#3872 ·
维护者通常 1 天内回复
-
type:task ux
难度 2/5 1-3 小时 新手友好度 72/100
elsa-workflows/elsa-foundation#5253 ·
维护者通常 1 天内回复