From 0841842285179a705c3e400d80a35a6908793b45 Mon Sep 17 00:00:00 2001 From: Jason Naylor Date: Wed, 20 May 2026 13:42:53 -0700 Subject: [PATCH 1/2] Add option to include Send/Recieve data in backup [LT-21752] * Add a user choice for including Send/Receive data on by default for projects using Send/Receive * Always restore the repository if it is in the backup but display a checkbox to show if the data is there * Only Block the restore if the backup does not have Send/Receive data in it * Update liblcm to the version including this backup option --- Build/SilVersions.props | 4 +- .../BackupProjectDlg.Designer.cs | 10 +++ .../BackupRestore/BackupProjectDlg.cs | 18 +++++ .../BackupRestore/BackupProjectDlg.resx | 47 ++++++++++--- .../BackupRestore/BackupProjectPresenter.cs | 15 +++++ .../RestoreProjectDlg.Designer.cs | 9 +++ .../BackupRestore/RestoreProjectDlg.cs | 12 ++++ .../BackupRestore/RestoreProjectDlg.resx | 34 +++++++++- .../BackupRestore/RestoreProjectPresenter.cs | 6 +- Src/FwCoreDlgs/FwCoreDlgs.Designer.cs | 11 +++- Src/FwCoreDlgs/FwCoreDlgs.resx | 3 + .../RestoreProjectPresenterTests.cs | 66 +++++++++++++++---- 12 files changed, 204 insertions(+), 31 deletions(-) diff --git a/Build/SilVersions.props b/Build/SilVersions.props index 71820f8aca..f4c469a691 100644 --- a/Build/SilVersions.props +++ b/Build/SilVersions.props @@ -1,5 +1,5 @@ - - 11.0.0-beta0161 + 11.0.0-beta0166 18.0.0-beta0013 18.0.0-beta0012 6.0.0-beta0065 diff --git a/Src/FwCoreDlgs/BackupRestore/BackupProjectDlg.Designer.cs b/Src/FwCoreDlgs/BackupRestore/BackupProjectDlg.Designer.cs index da4f95fa8f..da1ac09b49 100644 --- a/Src/FwCoreDlgs/BackupRestore/BackupProjectDlg.Designer.cs +++ b/Src/FwCoreDlgs/BackupRestore/BackupProjectDlg.Designer.cs @@ -36,6 +36,7 @@ private void InitializeComponent() this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(BackupProjectDlg)); this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.m_sendReceiveData = new System.Windows.Forms.CheckBox(); this.m_spellCheckAdditions = new System.Windows.Forms.CheckBox(); this.m_supportingFiles = new System.Windows.Forms.CheckBox(); this.m_linkedFiles = new System.Windows.Forms.CheckBox(); @@ -55,6 +56,7 @@ private void InitializeComponent() // // groupBox1 // + this.groupBox1.Controls.Add(this.m_sendReceiveData); this.groupBox1.Controls.Add(this.m_spellCheckAdditions); this.groupBox1.Controls.Add(this.m_supportingFiles); this.groupBox1.Controls.Add(this.m_linkedFiles); @@ -71,6 +73,13 @@ private void InitializeComponent() this.helpProvider.SetShowHelp(this.m_spellCheckAdditions, ((bool)(resources.GetObject("m_spellCheckAdditions.ShowHelp")))); this.m_spellCheckAdditions.UseVisualStyleBackColor = true; // + // m_sendReceiveData + // + resources.ApplyResources(this.m_sendReceiveData, "m_sendReceiveData"); + this.m_sendReceiveData.ForeColor = System.Drawing.SystemColors.ControlText; + this.m_sendReceiveData.Name = "m_sendReceiveData"; + this.m_sendReceiveData.UseVisualStyleBackColor = true; + // // m_supportingFiles // resources.ApplyResources(this.m_supportingFiles, "m_supportingFiles"); @@ -187,5 +196,6 @@ private void InitializeComponent() private System.Windows.Forms.ToolTip toolTip; private System.Windows.Forms.HelpProvider helpProvider; private System.Windows.Forms.CheckBox m_spellCheckAdditions; + private System.Windows.Forms.CheckBox m_sendReceiveData; } } \ No newline at end of file diff --git a/Src/FwCoreDlgs/BackupRestore/BackupProjectDlg.cs b/Src/FwCoreDlgs/BackupRestore/BackupProjectDlg.cs index b34bcb45a5..55abbc739f 100644 --- a/Src/FwCoreDlgs/BackupRestore/BackupProjectDlg.cs +++ b/Src/FwCoreDlgs/BackupRestore/BackupProjectDlg.cs @@ -62,6 +62,15 @@ public BackupProjectDlg(LcmCache cache, m_supportingFiles.Enabled = false; } + if (m_presenter.SendReceiveDataExists) + { + m_sendReceiveData.Checked = true; + } + else + { + m_sendReceiveData.Enabled = false; + } + DestinationFolder = FwDirectoryFinder.DefaultBackupDirectory; if (File.Exists(m_presenter.PersistanceFilePath)) { @@ -240,6 +249,15 @@ public bool IncludeSpellCheckAdditions set { m_spellCheckAdditions.Checked = value; } } + /// + /// Whether or not user wants Send/Receive repository data in the backup. + /// + public bool IncludeSendReceiveData + { + get { return m_sendReceiveData.Checked; } + set { m_sendReceiveData.Checked = value; } + } + /// /// Read/Write the comment from/to the dialog text control. /// diff --git a/Src/FwCoreDlgs/BackupRestore/BackupProjectDlg.resx b/Src/FwCoreDlgs/BackupRestore/BackupProjectDlg.resx index 2006527ad6..44af25dde0 100644 --- a/Src/FwCoreDlgs/BackupRestore/BackupProjectDlg.resx +++ b/Src/FwCoreDlgs/BackupRestore/BackupProjectDlg.resx @@ -154,6 +154,33 @@ groupBox1 + 1 + + + True + + + 15, 113 + + + 200, 17 + + + 5 + + + Send/Receive data (repository history) + + + m_sendReceiveData + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox1 + + 0 @@ -241,7 +268,7 @@ 12, 12 - 555, 148 + 555, 171 1 @@ -265,7 +292,7 @@ True - 9, 174 + 9, 197 54, 13 @@ -289,7 +316,7 @@ 7 - 12, 194 + 12, 217 555, 20 @@ -313,7 +340,7 @@ True - 12, 229 + 12, 252 46, 13 @@ -337,7 +364,7 @@ 5 - 12, 251 + 12, 274 476, 20 @@ -358,7 +385,7 @@ 4 - 494, 248 + 494, 271 73, 23 @@ -385,7 +412,7 @@ Bottom, Right - 328, 290 + 328, 313 75, 23 @@ -412,7 +439,7 @@ Bottom, Right - 409, 290 + 409, 313 75, 23 @@ -439,7 +466,7 @@ Bottom, Right - 491, 290 + 491, 313 75, 23 @@ -475,7 +502,7 @@ 6, 13 - 581, 326 + 581, 349 Back up this Project diff --git a/Src/FwCoreDlgs/BackupRestore/BackupProjectPresenter.cs b/Src/FwCoreDlgs/BackupRestore/BackupProjectPresenter.cs index 2a0415a2c2..01a3947e14 100644 --- a/Src/FwCoreDlgs/BackupRestore/BackupProjectPresenter.cs +++ b/Src/FwCoreDlgs/BackupRestore/BackupProjectPresenter.cs @@ -52,6 +52,21 @@ internal String PersistanceFilePath } } + /// + /// Returns true if the project has Send/Receive repository data (.hg or OtherRepositories). + /// + internal bool SendReceiveDataExists + { + get + { + var projectFolder = m_cache.ProjectId.ProjectFolder; + return Directory.Exists(Path.Combine(projectFolder, ".hg")) || + (Directory.Exists(LcmFileHelper.GetOtherRepositoriesDir(projectFolder)) && + Directory.EnumerateDirectories(LcmFileHelper.GetOtherRepositoriesDir(projectFolder)) + .Any(dir => Directory.Exists(Path.Combine(dir, ".hg")))); + } + } + /// /// If the SupportingFiles folder contains any files return true. Otherwise resturn false. /// diff --git a/Src/FwCoreDlgs/BackupRestore/RestoreProjectDlg.Designer.cs b/Src/FwCoreDlgs/BackupRestore/RestoreProjectDlg.Designer.cs index 39ba77413a..f16257c816 100644 --- a/Src/FwCoreDlgs/BackupRestore/RestoreProjectDlg.Designer.cs +++ b/Src/FwCoreDlgs/BackupRestore/RestoreProjectDlg.Designer.cs @@ -63,6 +63,7 @@ private void InitializeComponent() this.m_linkedFiles = new CheckBox(); this.m_supportingFiles = new CheckBox(); this.m_gbAlsoRestore = new GroupBox(); + this.m_sendReceiveData = new CheckBox(); this.m_spellCheckAdditions = new CheckBox(); this.m_btnOk = new Button(); this.m_lblOtherBackupIncludes = new Label(); @@ -178,6 +179,7 @@ private void InitializeComponent() // m_gbAlsoRestore // resources.ApplyResources(this.m_gbAlsoRestore, "m_gbAlsoRestore"); + this.m_gbAlsoRestore.Controls.Add(this.m_sendReceiveData); this.m_gbAlsoRestore.Controls.Add(this.m_spellCheckAdditions); this.m_gbAlsoRestore.Controls.Add(this.m_supportingFiles); this.m_gbAlsoRestore.Controls.Add(this.m_linkedFiles); @@ -185,6 +187,12 @@ private void InitializeComponent() this.m_gbAlsoRestore.Name = "m_gbAlsoRestore"; this.m_gbAlsoRestore.TabStop = false; // + // m_sendReceiveData + // + resources.ApplyResources(this.m_sendReceiveData, "m_sendReceiveData"); + this.m_sendReceiveData.Name = "m_sendReceiveData"; + this.m_sendReceiveData.UseVisualStyleBackColor = true; + // // m_spellCheckAdditions // resources.ApplyResources(this.m_spellCheckAdditions, "m_spellCheckAdditions"); @@ -397,6 +405,7 @@ private void InitializeComponent() private Label m_lblOtherBackupIncludes; private GroupBox m_gbBackupProperties; private CheckBox m_spellCheckAdditions; + private CheckBox m_sendReceiveData; private GroupBox m_gbRestoreAs; private RadioButton m_rdoUseOriginalName; private RadioButton m_rdoRestoreToName; diff --git a/Src/FwCoreDlgs/BackupRestore/RestoreProjectDlg.cs b/Src/FwCoreDlgs/BackupRestore/RestoreProjectDlg.cs index 6fcadfa30d..7c44780f76 100644 --- a/Src/FwCoreDlgs/BackupRestore/RestoreProjectDlg.cs +++ b/Src/FwCoreDlgs/BackupRestore/RestoreProjectDlg.cs @@ -222,6 +222,15 @@ public bool SpellCheckAdditions set { m_spellCheckAdditions.Checked = value; } } + /// + /// Whether or not user wants Send/Receive repository data restored. + /// + public bool SendReceiveData + { + get { return m_sendReceiveData.Checked; } + set { m_sendReceiveData.Checked = value; } + } + /// ------------------------------------------------------------------------------------ /// /// Sets the backup file settings and updates the dialog controls accordingly @@ -363,6 +372,8 @@ private void SetDialogControlsFromBackupSettings(BackupFileSettings settings, St m_supportingFiles.Enabled = settings.IncludeSupportingFiles; m_spellCheckAdditions.Checked = settings.IncludeSpellCheckAdditions; m_spellCheckAdditions.Enabled = settings.IncludeSpellCheckAdditions; + m_sendReceiveData.Checked = settings.IncludeSendReceiveData; + m_sendReceiveData.Enabled = false; if (m_rdoDefaultFolder.Checked) m_lblDefaultBackupIncludes.Text = m_presenter.IncludesFiles(settings); else @@ -591,6 +602,7 @@ private void UpdateSettingsFromControls() m_settings.IncludeLinkedFiles = LinkedFiles; m_settings.IncludeSupportingFiles = SupportingFiles; m_settings.IncludeSpellCheckAdditions = SpellCheckAdditions; + m_settings.IncludeSendReceiveData = SendReceiveData; } /// ------------------------------------------------------------------------------------ diff --git a/Src/FwCoreDlgs/BackupRestore/RestoreProjectDlg.resx b/Src/FwCoreDlgs/BackupRestore/RestoreProjectDlg.resx index e9bd873142..1b3f21734d 100644 --- a/Src/FwCoreDlgs/BackupRestore/RestoreProjectDlg.resx +++ b/Src/FwCoreDlgs/BackupRestore/RestoreProjectDlg.resx @@ -550,6 +550,36 @@ m_gbAlsoRestore + 1 + + + True + + + False + + + 8, 111 + + + 250, 17 + + + 4 + + + Send/&Receive data (repository history) + + + m_sendReceiveData + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + m_gbAlsoRestore + + 0 @@ -559,7 +589,7 @@ 15, 258 - 521, 135 + 521, 158 6 @@ -1153,7 +1183,7 @@ 6, 13 - 550, 447 + 550, 470 566, 485 diff --git a/Src/FwCoreDlgs/BackupRestore/RestoreProjectPresenter.cs b/Src/FwCoreDlgs/BackupRestore/RestoreProjectPresenter.cs index f1e2a25aaf..9b71dd1429 100644 --- a/Src/FwCoreDlgs/BackupRestore/RestoreProjectPresenter.cs +++ b/Src/FwCoreDlgs/BackupRestore/RestoreProjectPresenter.cs @@ -93,6 +93,8 @@ internal String IncludesFiles(BackupFileSettings settings) itemsBackedUp.Add(FwCoreDlgs.ksSupportingFilesRestoreDlg); if (settings.IncludeSpellCheckAdditions) itemsBackedUp.Add(FwCoreDlgs.ksSpellingFilesRestoreDlg); + if (settings.IncludeSendReceiveData) + itemsBackedUp.Add(FwCoreDlgs.ksSendReceiveDataRestoreDlg); int numberOfFileSetsBackedUp = itemsBackedUp.Count; if (numberOfFileSetsBackedUp == 0) @@ -139,8 +141,8 @@ internal bool IsOkayToRestoreProject() if (!m_restoreProjectView.Settings.ProjectExists) return true; - // If the user is using Send/Receive, it is NOT OK to restore - if (m_restoreProjectView.Settings.UsingSendReceive) + // If the user is using Send/Receive and the backup doesn't include S/R data, it is NOT OK to restore + if (m_restoreProjectView.Settings.UsingSendReceive && !m_restoreProjectView.Settings.IncludeSendReceiveData) { MessageBox.Show(FwCoreDlgs.ksBackupCantRestoreWhenUsingSRMsg, FwCoreDlgs.ksBackupCantRestoreWhenUsingSRCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); diff --git a/Src/FwCoreDlgs/FwCoreDlgs.Designer.cs b/Src/FwCoreDlgs/FwCoreDlgs.Designer.cs index 4ef33fe174..bfd2e8dc3b 100644 --- a/Src/FwCoreDlgs/FwCoreDlgs.Designer.cs +++ b/Src/FwCoreDlgs/FwCoreDlgs.Designer.cs @@ -1229,7 +1229,16 @@ public static string ksSpellingFilesRestoreDlg { return ResourceManager.GetString("ksSpellingFilesRestoreDlg", resourceCulture); } } - + + /// + /// Looks up a localized string similar to Send/Receive data. + /// + public static string ksSendReceiveDataRestoreDlg { + get { + return ResourceManager.GetString("ksSendReceiveDataRestoreDlg", resourceCulture); + } + } + /// /// Looks up a localized string similar to {0} Stem. /// diff --git a/Src/FwCoreDlgs/FwCoreDlgs.resx b/Src/FwCoreDlgs/FwCoreDlgs.resx index 0ce1578c2c..e2e119b0e9 100644 --- a/Src/FwCoreDlgs/FwCoreDlgs.resx +++ b/Src/FwCoreDlgs/FwCoreDlgs.resx @@ -830,6 +830,9 @@ Enter a shorter name. Spelling dictionary + + Send/Receive data + and {0}. diff --git a/Src/FwCoreDlgs/FwCoreDlgsTests/RestoreProjectPresenterTests.cs b/Src/FwCoreDlgs/FwCoreDlgsTests/RestoreProjectPresenterTests.cs index fd7e7ce72b..e3853e30fe 100644 --- a/Src/FwCoreDlgs/FwCoreDlgsTests/RestoreProjectPresenterTests.cs +++ b/Src/FwCoreDlgs/FwCoreDlgsTests/RestoreProjectPresenterTests.cs @@ -4,27 +4,65 @@ // // File: RestoreProjectPresenterTests.cs // Responsibility: FW Team -// DISABLED: BackupProjectSettings API has been refactored - tests use obsolete constructor and properties +using System.IO; using NUnit.Framework; +using SIL.FieldWorks.FwCoreDlgs.BackupRestore; +using SIL.LCModel; +using SIL.LCModel.DomainServices.BackupRestore; +using SIL.LCModel.Utils; namespace SIL.FieldWorks.FwCoreDlgs { - /// - /// Historical tests for RestoreProjectPresenter. - /// The original tests used backup/restore APIs that have since been refactored. - /// [TestFixture] - [Ignore("Obsolete: backup/restore presenter tests need rewrite after API refactor.")] public class RestoreProjectPresenterTests { + private BackupFileSettings CreateBackupFileSettingsWithFlags( + bool config = false, bool linked = false, bool supporting = false, + bool spellCheck = false, bool sendReceive = false) + { + var backupSettings = new BackupFileSettings( + Path.ChangeExtension("dummy", LcmFileHelper.ksFwBackupFileExtension), false); + ReflectionHelper.SetField(backupSettings, "m_projectName", "dummy"); + ReflectionHelper.SetField(backupSettings, "m_configurationSettings", config); + ReflectionHelper.SetField(backupSettings, "m_linkedFiles", linked); + ReflectionHelper.SetField(backupSettings, "m_supportingFiles", supporting); + ReflectionHelper.SetField(backupSettings, "m_spellCheckAdditions", spellCheck); + ReflectionHelper.SetField(backupSettings, "m_sendReceiveData", sendReceive); + return backupSettings; + } + + [Test] + public void IncludesFiles_WithSendReceiveData_ShowsInLabel() + { + var presenter = new RestoreProjectPresenter(null); + var settings = CreateBackupFileSettingsWithFlags(sendReceive: true); + string result = presenter.IncludesFiles(settings); + Assert.That(result, Is.EqualTo("Send/Receive data")); + } + + [Test] + public void IncludesFiles_WithoutSendReceiveData_OmitsFromLabel() + { + var presenter = new RestoreProjectPresenter(null); + var settings = CreateBackupFileSettingsWithFlags(config: true, sendReceive: false); + string result = presenter.IncludesFiles(settings); + Assert.That(result, Does.Not.Contain("Send/Receive data")); + } + [Test] - public void ObsoletePresenterApi_Disabled() + public void IncludesFiles_AllFlags_CorrectCombination() { - Assert.Ignore( - "Obsolete: legacy presenter tests are archived behind RUN_LW_LEGACY_TESTS " + - "and need to be rewritten against the current backup/restore APIs." - ); + var presenter = new RestoreProjectPresenter(null); + var settings = CreateBackupFileSettingsWithFlags( + config: true, linked: true, supporting: true, + spellCheck: true, sendReceive: true); + string result = presenter.IncludesFiles(settings); + Assert.That(result, Does.Contain("Configuration settings")); + Assert.That(result, Does.Contain("Linked files")); + Assert.That(result, Does.Contain("Supporting Files")); + Assert.That(result, Does.Contain("Spelling dictionary")); + Assert.That(result, Does.Contain("Send/Receive data")); } } } @@ -73,7 +111,7 @@ public void TearDown() [Test] public void VerifyStringForBackupPropertiesLabel() { - var restoreProjectPresenter = new RestoreProjectPresenter(null, string.Empty); + var restoreProjectPresenter = new RestoreProjectPresenter(null); BackupFileSettings backupSettings = new BackupFileSettings( Path.ChangeExtension("dummy", LcmFileHelper.ksFwBackupFileExtension), false); // This is needed to thwart BackupFileSettings's normal logic to populate the flags @@ -114,7 +152,7 @@ public void VerifyStringForBackupPropertiesLabel() public void DefaultBackupFile_NoBackupFilesAvailable() { m_fileOs.ExistingDirectories.Add(FwDirectoryFinder.DefaultBackupDirectory); - RestoreProjectPresenter presenter = new RestoreProjectPresenter(null, string.Empty); + RestoreProjectPresenter presenter = new RestoreProjectPresenter(null); Assert.That(presenter.DefaultProjectName, Is.EqualTo(String.Empty)); } @@ -134,7 +172,7 @@ public void DefaultBackupFile_BackupForCurrentProjectExists() backupSettings.BackupTime = backupSettings.BackupTime.AddHours(-3); string backupFileName2 = backupSettings.ZipFileName; m_fileOs.AddExistingFile(backupFileName2); - RestoreProjectPresenter presenter = new RestoreProjectPresenter(null, string.Empty); + RestoreProjectPresenter presenter = new RestoreProjectPresenter(null); Assert.That(presenter.DefaultProjectName, Is.EqualTo(backupSettings.ProjectName)); } From 3bc4f51c692024722e48e1d92d4a45c0f023ec00 Mon Sep 17 00:00:00 2001 From: Jason Naylor Date: Thu, 21 May 2026 09:29:27 -0700 Subject: [PATCH 2/2] 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 --- Build/Manage-LocalLibraries.ps1 | 34 +++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/Build/Manage-LocalLibraries.ps1 b/Build/Manage-LocalLibraries.ps1 index a06f78c36d..2f5e7eb1e5 100644 --- a/Build/Manage-LocalLibraries.ps1 +++ b/Build/Manage-LocalLibraries.ps1 @@ -60,7 +60,7 @@ .PARAMETER Library Which library to set a version for (SetVersion mode only): - liblcm, libpalaso, chorus, machine, or l10nsharp. + lcm, palaso, chorus, machine, or l10nsharp. .PARAMETER Version Sets the version in SilVersions.props (SetVersion mode). Use to revert @@ -75,7 +75,7 @@ Packs libpalaso (from env var) and then chorus from the given path. .EXAMPLE - .\Build\Manage-LocalLibraries.ps1 -Library libpalaso -Version 17.0.0 + .\Build\Manage-LocalLibraries.ps1 -Library palaso -Version 17.0.0 Sets libpalaso version to 17.0.0 in SilVersions.props (e.g. to revert). #> [CmdletBinding()] @@ -95,7 +95,7 @@ param( [switch]$L10nSharp, [string]$L10nSharpPath, - [ValidateSet('liblcm', 'libpalaso', 'chorus', 'machine', 'l10nsharp')] + [ValidateSet('palaso', 'lcm', 'chorus', 'machine', 'l10nsharp')] [string]$Library, [string]$Version @@ -108,7 +108,7 @@ $ErrorActionPreference = "Stop" # --------------------------------------------------------------------------- $LibraryConfig = @{ - libpalaso = @{ + palaso = @{ VersionProperty = 'SilLibPalasoVersion' PdbRelativeDir = 'output/Debug/net462' CachePrefixes = @( @@ -118,7 +118,7 @@ $LibraryConfig = @{ ) EnvVar = 'LIBPALASO_PATH' } - liblcm = @{ + lcm = @{ VersionProperty = 'SilLcmVersion' PdbRelativeDir = 'artifacts/Debug/net462' CachePrefixes = @('sil.lcmodel') @@ -150,7 +150,7 @@ $LibraryConfig = @{ } # Pack order: libpalaso first (other libraries may depend on it) -$PackOrder = @('libpalaso', 'l10nsharp', 'liblcm', 'chorus', 'machine') +$PackOrder = @('palaso', 'l10nsharp', 'lcm', 'chorus', 'machine') # --------------------------------------------------------------------------- # Read SilVersions.props @@ -188,7 +188,21 @@ function Update-VersionAndClearCache { $cfg = $LibraryConfig[$LibName] $node = Get-VersionNode $LibName $node.InnerText = $NewVersion - $versionProps.Save($versionPropsPath) + + # Save with XmlWriter to preserve tab indentation (XmlDocument.Save() converts tabs to spaces) + $writerSettings = New-Object System.Xml.XmlWriterSettings + $writerSettings.Indent = $true + $writerSettings.IndentChars = "`t" + $writerSettings.NewLineChars = "`r`n" + $writerSettings.Encoding = New-Object System.Text.UTF8Encoding($false) # UTF-8 without BOM + $writerSettings.OmitXmlDeclaration = -not $versionProps.FirstChild.NodeType.Equals([System.Xml.XmlNodeType]::XmlDeclaration) + $writer = [System.Xml.XmlWriter]::Create($versionPropsPath, $writerSettings) + try { + $versionProps.WriteTo($writer) + } finally { + $writer.Close() + } + Write-Host "Updated SilVersions.props ($($cfg.VersionProperty) = $NewVersion)" -ForegroundColor Yellow $packagesDir = Join-Path $repoRoot "packages" @@ -345,8 +359,8 @@ function Invoke-PackLibrary { # Map switches and explicit paths to library names $switchMap = @{ - libpalaso = @{ Enabled = [bool]$Palaso; ExplicitPath = $PalasoPath } - liblcm = @{ Enabled = [bool]$Lcm; ExplicitPath = $LcmPath } + palaso = @{ Enabled = [bool]$Palaso; ExplicitPath = $PalasoPath } + lcm = @{ Enabled = [bool]$Lcm; ExplicitPath = $LcmPath } chorus = @{ Enabled = [bool]$Chorus; ExplicitPath = $ChorusPath } machine = @{ Enabled = [bool]$Machine; ExplicitPath = $MachinePath } l10nsharp = @{ Enabled = [bool]$L10nSharp; ExplicitPath = $L10nSharpPath } @@ -436,5 +450,5 @@ elseif ($Library -and $Version) { Write-Host "Run .\build.ps1 to restore and build with the new version." -ForegroundColor Cyan } else { - 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" + 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" }