Fix modScriptPackages holding full paths instead of package names#93
Fix modScriptPackages holding full paths instead of package names#93marlonrichert wants to merge 1 commit into
Conversation
|
Can you clarify whether this is specific to the cross-platform Powershell? |
|
It's not specific to cross-platform PowerShell. Rather, it's specific to the code in
X2ModBuildCommon/build_common.ps1 Line 47 in 14e97e1
X2ModBuildCommon/build_common.ps1 Line 243 in 14e97e1 But To make the assignment work, PowerShell silently converts each This becomes a problem in X2ModBuildCommon/build_common.ps1 Line 13 in 14e97e1 Thus, [bool]_HasNativePackages() {
# Check if this is a Highlander and we need to cook things
$anynative = $false
foreach ($name in $this.modScriptPackages)
{
if ($global:nativescriptpackages.Contains($name)) {
$anynative = $true
break
}
}
return $anynative
}Likewise, [void]_CopyScriptPackages() {
# copy packages to staging
foreach ($name in $this.modScriptPackages) {
if ($this.cookHL -and $global:nativescriptpackages.Contains($name))
{
# This is a native (cooked) script package -- copy important upks
Copy-Item "$($this.cookerOutputPath)\$name.upk" "$($this.stagingPath)\CookedPCConsole" -Force -WarningAction SilentlyContinue
Copy-Item "$($this.cookerOutputPath)\$name.upk.uncompressed_size" "$($this.stagingPath)\CookedPCConsole" -Force -WarningAction SilentlyContinue
Write-Host "$($this.cookerOutputPath)\$name.upk"
}
else
{
# Or this is a non-native package
Copy-Item "$($this.sdkPath)\XComGame\Script\$name.u" "$($this.stagingPath)\Script" -Force -WarningAction SilentlyContinue
Write-Host "$($this.sdkPath)\XComGame\Script\$name.u"
}
}
}My commit fixes this by populating |
|
Right, but the Highlander X2ModBuildCommon (which has an older version) already has this line: If your explanation is right, then the current Highlander build should also be completely broken, but it isn't, at least with the classic powershell. |
|
OK, interesting. I'll have to investigate further. |
$this.modScriptPackages is typed [string[]], but was assigned the raw Get-ChildItem -Directory results (DirectoryInfo objects). PowerShell coerces each to its full path via ToString(), not just the folder name, so every later "$name.u" package-copy step built a garbage path. Because $ErrorActionPreference is "Stop", the resulting Copy-Item file-not-found is fatal, so the build fails outright. X2WOTCCommunityHighlander's build_common.ps1 has the same pattern (thismodpackages, assigned the same way) yet reportedly builds fine under classic Windows PowerShell 5.1. This project can only build under PowerShell Core/pwsh, and fails to build there without this fix - so the coercion behavior differs between those two PowerShell editions/runtimes. This is not platform-independent; it's specific to PowerShell Core/pwsh.
a276b8d to
4c43074
Compare
|
I need your help to resolve your question: Can you add a |
$this.modScriptPackages is typed [string[]], but was assigned the raw Get-ChildItem -Directory results (DirectoryInfo objects). PowerShell coerces each to its full path via ToString(), not just the folder name, so every later "$name.u" package-copy step built a garbage path. Platform-independent bug, not Linux-specific.