6.6 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |
|---|---|---|---|---|---|
|
2026-04-16T04:43:59.723876+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | 499179ba93465fb0 |
MigrateConfiguration
Documentation: ConfigurationMigration.cs
1. Purpose
This module implements a configuration migration mechanism for DataPRO installer custom actions. Its primary role is to preserve user- and application-specific settings from the most recently installed previous version of DataPRO when a new version is installed, ensuring continuity of configuration without overwriting user-modified values with fresh defaults. It operates during installation by reading the old configuration file (if present), comparing settings against the new defaults, and migrating only those that differ (with special handling for DownloadFolder to avoid reverting to outdated defaults). It also handles migration of license files (.lic) from previous installations.
2. Public Interface
The module is internal static class ConfigurationMigration. While not public, it exposes one method intended for use by the installer custom action infrastructure:
UpdateConfigurationIfPossible(string targetDir, Version installingVersion, string setupExeDir, out string result)
Purpose: Orchestrates configuration migration.
Behavior:- Determines the most recently installed previous version using
PreviousInstall.GetMostRecentlyInstalledSubKeyName. - Retrieves the installation path of that version via
PreviousInstall.GetMostRecentlyInstalledPath. - Calls
MigrateLicenseFileto copy license files. - Returns via
resulta status string indicating whether the config was updated, skipped, or failed. - Does not migrate
ApplicationSettingsorUserSettingssections itself—this appears to be omitted in the active code (commented out inMain). Only license migration is performed in the current implementation.
- Determines the most recently installed previous version using
Note: The
Main(string[] args)method isprivate staticand serves as the entry point for the custom action. It parses command-line arguments (targetDir,installingVersion,noUI,setupExeDir), initializes event logging, and callsUpdateConfigurationIfPossible. It also shows aMessageBoxwith migration results ifnoUI != "TRUE".
3. Invariants
- Version ordering: Migration only occurs if a strictly older version is detected (
installingVersionmust be greater than the previously installed version). - Path assumptions:
- The old config file is assumed to reside at
<oldInstallPath>\DataPRO.exe(viaStringResources.RegistryDataPROExe). - License files are searched up to 2 subdirectories deep from either the current install directory (
setupExeDir) or the old install path.
- The old config file is assumed to reside at
- Setting migration logic:
- A setting is migrated only if:
- It exists in both old and new config files.
- Its value in the old config differs from the new default (i.e., the value in the new config file before migration).
- Exception for
DownloadFolder: It is not migrated if the old value equalsStringResources.DataUpOneLevel(the old default), to avoid reverting to outdated paths.
- A setting is migrated only if:
- No partial migration of sections: If
MigrateSettingsfails for eitherUserSettingsorApplicationSettings, the entire section is skipped. - License file detection: A file is considered a DataPRO license only if it is a
.licfile containing both<License>and<LicenseAttributes>XML elements.
4. Dependencies
Internal dependencies (within module):
StringResources(fromMigrateConfiguration.Resources) — provides string constants (e.g.,DownloadFolder,UserSettings,ApplicationSettings,DataUpOneLevel,DataUpTwoLevels,ImportArchiveUpTwoLevels,DTSPlugins, etc.).PreviousInstall— used to query registry for previous installation metadata (GetMostRecentlyInstalledSubKeyName,GetMostRecentlyInstalledPath).ConfigInitializationHelper— used inMigrateSettingsviaGetNewSettings(not shown in this file; inferred from usage).SettingElementCollection,SettingElement,ClientSettingsSection,Configuration— fromSystem.Configuration.
External dependencies (imports):
System.ConfigurationSystem.Windows.Forms(forMessageBox.Show)System.IODTS.Common.UtilitiesInstaller.Common
Depended upon by:
- The Windows Installer custom action that invokes
ConfigurationMigration.Main(string[] args)with command-line arguments.
5. Gotchas
- Critical omission: The
Mainmethod contains commented-out code blocks that were intended to:- Pre-set
DownloadFolderandImportArchiveFolderto current defaults before migration. - Call
MigrateUserSettingsandMigrateAppSettings(viaUpdateConfigurationIfPossibleor directly). - Fix runtime module paths (
FixRunTimeModulesPath).
→ As written, only license migration is active. Configuration settings (UserSettings,ApplicationSettings) are not migrated in the current implementation.
- Pre-set
- Hardcoded recursion depth:
FindLicenseInPathonly searches 2 subdirectories deep (subDirectoriesToCheck = 2). Deeper nested license files will be missed. - Assumption of default install paths:
GetOldSettingsassumes the old config file is at<oldInstallPath>\DataPRO.exe. If the previous installation used a custom path, migration will fail. - No rollback on failure: If license copying fails, the error is reported but no cleanup or fallback occurs.
- Event logging is non-functional: The
EventLog.Sourceis set to"MySource"(hardcoded), but the source"DataPROInstaller"is created earlier. This mismatch may cause logging failures. noUIcheck is fragile:noUI != "TRUE"is case-sensitive and exact."true"or"True"would not suppress the UI.SettingElementCollectionmutability: The code removes and re-addsSettingElementinstances tonewSettings. This assumesSettingElementCollectionallows modification afterConfigurationload, which may be fragile depending on .NET version or config file locking.- Missing null checks:
GetConfigSettingsaccessesconfigurationSectionGroup.Sections[0]without verifyingSections.Count > 0, riskingIndexOutOfRangeExceptionif the section exists but is empty.
None identified from source alone for behavioral quirks beyond the above — but the commented-out code strongly suggests this module is partially implemented or in a transitional state.