diff --git a/tools/Invoke-RemoteInstall.ps1 b/tools/Invoke-RemoteInstall.ps1 index f3d02c0..02cad4b 100644 --- a/tools/Invoke-RemoteInstall.ps1 +++ b/tools/Invoke-RemoteInstall.ps1 @@ -147,7 +147,23 @@ function Get-ComponentRegistrationMode { if ($absentCount -eq $Components.Count) { return 'Absent' } if ($ownedCount -eq $Components.Count) { return 'Owned' } - throw 'Component registrations are a mixture of absent and existing entries. Refusing a deployment that could overwrite or delete unrelated registry state.' + + # An upgrade may introduce a component that did not exist in the currently + # deployed tree. Accept only that additive case: every existing registration + # was proven project-owned above, and every absent registration must also + # have no corresponding component file in the old release. An absent + # registration for an old file remains a suspicious partial state. + foreach ($component in $Components) { + $progIdKey = "HKLM:\SOFTWARE\Classes\$($component.ProgId)" + $clsidKey = "HKLM:\SOFTWARE\Classes\CLSID\$($component.ClassId)" + if (-not (Test-Path -LiteralPath $progIdKey) -and -not (Test-Path -LiteralPath $clsidKey)) { + $oldComponentPath = Join-Path $ExistingProjectPath $component.RelativePath + if (Test-Path -LiteralPath $oldComponentPath) { + throw "Component registration for existing file '$($component.RelativePath)' is absent. Refusing to repair a partial registration state." + } + } + } + return 'Owned' } function Restore-SiteState { @@ -259,6 +275,7 @@ $components = @( [PSCustomObject]@{ RelativePath = 'Framework\RequestContext.wsc'; ProgId = 'WscMvc.RequestContext'; ClassId = '{1C36FA55-34DF-4974-94B9-D657389362B2}' }, [PSCustomObject]@{ RelativePath = 'Framework\Router.wsc'; ProgId = 'WscMvc.Router'; ClassId = '{C92F9338-B478-4EAD-B865-892FFB1E1C51}' }, [PSCustomObject]@{ RelativePath = 'Framework\ViewRenderer.wsc'; ProgId = 'WscMvc.ViewRenderer'; ClassId = '{4948DF84-5DC6-448A-9F1B-EB596C28842B}' }, + [PSCustomObject]@{ RelativePath = 'Framework\Database.wsc'; ProgId = 'WscMvc.Database'; ClassId = '{E3F7C1A2-9B4D-4E6F-8C3A-2D5B7A9E1F04}' }, [PSCustomObject]@{ RelativePath = 'Framework\Application.wsc'; ProgId = 'WscMvc.Application'; ClassId = '{851C7763-1638-42FE-A166-BF3DD3A96A88}' }, [PSCustomObject]@{ RelativePath = 'Controllers\HomeController.wsc'; ProgId = 'WscMvc.HomeController'; ClassId = '{87488446-60BE-4068-8368-0B709BB68F3F}' }, [PSCustomObject]@{ RelativePath = 'test-app\Controllers\SelfTestController.wsc'; ProgId = 'WscMvc.SelfTestController'; ClassId = '{D2634944-4646-4C55-956E-4C05E7E10904}' } @@ -313,6 +330,7 @@ try { 'public\Default.asp', 'test-app\public\Default.asp', 'Framework\ViewRenderer.wsc', + 'Framework\Database.wsc', 'tools\Register-Components.ps1', 'tools\Setup-Site.ps1', 'tests\Invoke-SelfTest.ps1',