Skip to content

Commit 3bc4f51

Browse files
Make library name consistent for pack and version updates
* -Libary requried liblcm, while the default option wanted Lcm * File was written out with spaces but tabs were expected
1 parent 0841842 commit 3bc4f51

1 file changed

Lines changed: 24 additions & 10 deletions

File tree

Build/Manage-LocalLibraries.ps1

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
6161
.PARAMETER Library
6262
Which library to set a version for (SetVersion mode only):
63-
liblcm, libpalaso, chorus, machine, or l10nsharp.
63+
lcm, palaso, chorus, machine, or l10nsharp.
6464
6565
.PARAMETER Version
6666
Sets the version in SilVersions.props (SetVersion mode). Use to revert
@@ -75,7 +75,7 @@
7575
Packs libpalaso (from env var) and then chorus from the given path.
7676
7777
.EXAMPLE
78-
.\Build\Manage-LocalLibraries.ps1 -Library libpalaso -Version 17.0.0
78+
.\Build\Manage-LocalLibraries.ps1 -Library palaso -Version 17.0.0
7979
Sets libpalaso version to 17.0.0 in SilVersions.props (e.g. to revert).
8080
#>
8181
[CmdletBinding()]
@@ -95,7 +95,7 @@ param(
9595
[switch]$L10nSharp,
9696
[string]$L10nSharpPath,
9797

98-
[ValidateSet('liblcm', 'libpalaso', 'chorus', 'machine', 'l10nsharp')]
98+
[ValidateSet('palaso', 'lcm', 'chorus', 'machine', 'l10nsharp')]
9999
[string]$Library,
100100

101101
[string]$Version
@@ -108,7 +108,7 @@ $ErrorActionPreference = "Stop"
108108
# ---------------------------------------------------------------------------
109109

110110
$LibraryConfig = @{
111-
libpalaso = @{
111+
palaso = @{
112112
VersionProperty = 'SilLibPalasoVersion'
113113
PdbRelativeDir = 'output/Debug/net462'
114114
CachePrefixes = @(
@@ -118,7 +118,7 @@ $LibraryConfig = @{
118118
)
119119
EnvVar = 'LIBPALASO_PATH'
120120
}
121-
liblcm = @{
121+
lcm = @{
122122
VersionProperty = 'SilLcmVersion'
123123
PdbRelativeDir = 'artifacts/Debug/net462'
124124
CachePrefixes = @('sil.lcmodel')
@@ -150,7 +150,7 @@ $LibraryConfig = @{
150150
}
151151

152152
# Pack order: libpalaso first (other libraries may depend on it)
153-
$PackOrder = @('libpalaso', 'l10nsharp', 'liblcm', 'chorus', 'machine')
153+
$PackOrder = @('palaso', 'l10nsharp', 'lcm', 'chorus', 'machine')
154154

155155
# ---------------------------------------------------------------------------
156156
# Read SilVersions.props
@@ -188,7 +188,21 @@ function Update-VersionAndClearCache {
188188
$cfg = $LibraryConfig[$LibName]
189189
$node = Get-VersionNode $LibName
190190
$node.InnerText = $NewVersion
191-
$versionProps.Save($versionPropsPath)
191+
192+
# Save with XmlWriter to preserve tab indentation (XmlDocument.Save() converts tabs to spaces)
193+
$writerSettings = New-Object System.Xml.XmlWriterSettings
194+
$writerSettings.Indent = $true
195+
$writerSettings.IndentChars = "`t"
196+
$writerSettings.NewLineChars = "`r`n"
197+
$writerSettings.Encoding = New-Object System.Text.UTF8Encoding($false) # UTF-8 without BOM
198+
$writerSettings.OmitXmlDeclaration = -not $versionProps.FirstChild.NodeType.Equals([System.Xml.XmlNodeType]::XmlDeclaration)
199+
$writer = [System.Xml.XmlWriter]::Create($versionPropsPath, $writerSettings)
200+
try {
201+
$versionProps.WriteTo($writer)
202+
} finally {
203+
$writer.Close()
204+
}
205+
192206
Write-Host "Updated SilVersions.props ($($cfg.VersionProperty) = $NewVersion)" -ForegroundColor Yellow
193207

194208
$packagesDir = Join-Path $repoRoot "packages"
@@ -345,8 +359,8 @@ function Invoke-PackLibrary {
345359

346360
# Map switches and explicit paths to library names
347361
$switchMap = @{
348-
libpalaso = @{ Enabled = [bool]$Palaso; ExplicitPath = $PalasoPath }
349-
liblcm = @{ Enabled = [bool]$Lcm; ExplicitPath = $LcmPath }
362+
palaso = @{ Enabled = [bool]$Palaso; ExplicitPath = $PalasoPath }
363+
lcm = @{ Enabled = [bool]$Lcm; ExplicitPath = $LcmPath }
350364
chorus = @{ Enabled = [bool]$Chorus; ExplicitPath = $ChorusPath }
351365
machine = @{ Enabled = [bool]$Machine; ExplicitPath = $MachinePath }
352366
l10nsharp = @{ Enabled = [bool]$L10nSharp; ExplicitPath = $L10nSharpPath }
@@ -436,5 +450,5 @@ elseif ($Library -and $Version) {
436450
Write-Host "Run .\build.ps1 to restore and build with the new version." -ForegroundColor Cyan
437451
}
438452
else {
439-
throw "Nothing to do. Use -Palaso/-Lcm/-Chorus/-Machine/-L10nSharp switches to pack, or -Library and -Version to set a version.`nExamples:`n .\Build\Manage-LocalLibraries.ps1 -Palaso -PalasoPath C:\Repos\libpalaso`n .\Build\Manage-LocalLibraries.ps1 -Palaso -Chorus`n .\Build\Manage-LocalLibraries.ps1 -Machine -MachinePath C:\Repos\machine`n .\Build\Manage-LocalLibraries.ps1 -Library l10nsharp -Version 10.0.0`n .\Build\Manage-LocalLibraries.ps1 -Library libpalaso -Version 17.0.0"
453+
throw "Nothing to do. Use -Palaso/-Lcm/-Chorus/-Machine/-L10nSharp switches to pack, or -Library and -Version to set a version.`nExamples:`n .\Build\Manage-LocalLibraries.ps1 -Palaso -PalasoPath C:\Repos\libpalaso`n .\Build\Manage-LocalLibraries.ps1 -Palaso -Chorus`n .\Build\Manage-LocalLibraries.ps1 -Machine -MachinePath C:\Repos\machine`n .\Build\Manage-LocalLibraries.ps1 -Library l10nsharp -Version 10.0.0`n .\Build\Manage-LocalLibraries.ps1 -Library palaso -Version 17.0.0"
440454
}

0 commit comments

Comments
 (0)