Staging flattens a culture directory's .psd1 into the output root

未关闭 适合新手
#211 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
74/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
powershell
领域
build-system

调研方向

从 issue 中描述的 Build-PSBuildModule 暂存逻辑开始,并在更改 depth 行为之前检查相关 issue #206、#207 和 #210。验证根 manifest 和模块文件仍能正确暂存,同时本地化的 en-US/Messages.psd1 不会被复制到输出根目录。

由索引模型根据 Issue 内容生成。

描述

bug

Found while researching #207. Reading the code confirms it; it is also visible in that issue's own reproduction output.

What happens

Build-PSBuildModule stages the module's loose files with:

$getChildItemSplat = @{
    Path    = $Path
    Include = "*.psm1", "*.psd1", "*.ps1xml"
    Depth   = 1
}
Get-ChildItem @getChildItemSplat |
    Copy-Item -Destination $DestinationPath -Force

-Depth 1 implies recursion one level down, so this matches en-US/Messages.psd1 — and Copy-Item -Destination $DestinationPath writes it flat into the output root, discarding the directory it came from.

A module with a localized Messages.psd1 therefore builds an output containing a stray Messages.psd1 at the root that nothing reads. If CopyDirectories also names en-US, the correct copy is there too, and the built tree carries both.

Why it matters, mildly

Nothing breaks. Import-LocalizedData resolves through the culture directory and ignores the stray file, and a module without a culture directory never hits it. The costs are that the published package carries a file that serves no purpose and misleads anyone reading the tree, and that a consumer debugging localization finds two copies of the same file and has to work out which one is live.

It is also the same root cause as #210, seen from the other side: the depth-1 glob is trying to serve two purposes — collect the root manifest and module file, and leave everything else to CopyDirectories — and reaches one level too far.

Options

  1. Drop -Depth 1, so the glob matches only the root. The manifest and root module are always at the root, so nothing intended is lost. Anything deeper is CopyDirectories' job. Smallest change.
  2. Preserve relative paths when copying, so en-US/Messages.psd1 lands at en-US/Messages.psd1. More faithful, and it would partly address #210 — but it makes the glob a second, implicit staging mechanism competing with CopyDirectories, which is how the two got tangled in the first place.
  3. Leave it. The stray file is inert.

(1) looks right, and it is a one-word deletion. But -Depth 1 was presumably added deliberately at some point, and I could not find what for — worth a moment's thought before removing it, in case some layout depends on it.

Related: #206, #207 and #210 are all in this same staging logic. Worth deciding together.

主要语言
PowerShell
星标
145
派生
27
平均合并
10 小时 16 分钟
30 天内合并 PR
34

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

psake/PowerShellBuild 的其他 Issue

查看 psake/PowerShellBuild 的全部 Issue

相似的 Issue

更多 Build System Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。