Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

74 строки
3.4KB

  1. [CmdletBinding()]
  2. param(
  3. [string]$ProjectRoot
  4. )
  5. if (-not $ProjectRoot) {
  6. $ProjectRoot = Split-Path -Parent $PSScriptRoot
  7. }
  8. # NOTE (see docs/DECISIONS.md): on this host, `regsvr32 /s /u component.wsc` reports
  9. # exit code 0 but leaves the ProgID/CLSID registry entries in place - verified experimentally,
  10. # not a theoretical concern. regsvr32 /u is still attempted first (best effort, harmless if it
  11. # no-ops), then registry state is checked and, if the entries survived, they are removed
  12. # explicitly - scoped to exactly this project's ProgID/CLSID pairs so an unrelated component
  13. # can never be touched even if it happened to reuse a ProgID string.
  14. $components = @(
  15. @{ Path = (Join-Path $ProjectRoot 'test-app\Controllers\SelfTestController.wsc'); ProgId = 'WscMvc.SelfTestController'; ClassId = '{D2634944-4646-4C55-956E-4C05E7E10904}' },
  16. @{ Path = (Join-Path $ProjectRoot 'Controllers\HomeController.wsc'); ProgId = 'WscMvc.HomeController'; ClassId = '{87488446-60BE-4068-8368-0B709BB68F3F}' },
  17. @{ Path = (Join-Path $ProjectRoot 'Framework\Application.wsc'); ProgId = 'WscMvc.Application'; ClassId = '{851C7763-1638-42FE-A166-BF3DD3A96A88}' },
  18. @{ Path = (Join-Path $ProjectRoot 'Framework\ViewRenderer.wsc'); ProgId = 'WscMvc.ViewRenderer'; ClassId = '{4948DF84-5DC6-448A-9F1B-EB596C28842B}' },
  19. @{ Path = (Join-Path $ProjectRoot 'Framework\Database.wsc'); ProgId = 'WscMvc.Database'; ClassId = '{E3F7C1A2-9B4D-4E6F-8C3A-2D5B7A9E1F04}' },
  20. @{ Path = (Join-Path $ProjectRoot 'Framework\Router.wsc'); ProgId = 'WscMvc.Router'; ClassId = '{C92F9338-B478-4EAD-B865-892FFB1E1C51}' },
  21. @{ Path = (Join-Path $ProjectRoot 'Framework\RequestContext.wsc'); ProgId = 'WscMvc.RequestContext'; ClassId = '{1C36FA55-34DF-4974-94B9-D657389362B2}' }
  22. )
  23. function Remove-ProjectComponent {
  24. param([string]$ProgId, [string]$ClassId)
  25. $progIdKey = "HKLM:\SOFTWARE\Classes\$ProgId"
  26. $clsidKey = "HKLM:\SOFTWARE\Classes\CLSID\$ClassId"
  27. $registeredClassId = $null
  28. if (Test-Path "$progIdKey\CLSID") {
  29. $registeredClassId = (Get-ItemProperty "$progIdKey\CLSID" -ErrorAction SilentlyContinue).'(default)'
  30. }
  31. if (-not (Test-Path $progIdKey) -and -not (Test-Path $clsidKey)) {
  32. Write-Output " Already absent: $ProgId / $ClassId"
  33. return
  34. }
  35. if ($registeredClassId -and $registeredClassId -ne $ClassId) {
  36. throw "Refusing to remove '$ProgId': registered CLSID ($registeredClassId) does not match this project's expected CLSID ($ClassId). This ProgID may belong to a different component."
  37. }
  38. if (Test-Path $progIdKey) {
  39. Remove-Item -Path $progIdKey -Recurse -Force
  40. Write-Output " Removed $progIdKey"
  41. }
  42. if (Test-Path $clsidKey) {
  43. Remove-Item -Path $clsidKey -Recurse -Force
  44. Write-Output " Removed $clsidKey"
  45. }
  46. }
  47. foreach ($component in $components) {
  48. $path = $component.Path
  49. if (-not (Test-Path $path)) {
  50. Write-Warning "Component not found, skipping: $path"
  51. continue
  52. }
  53. Write-Output "Unregistering $path"
  54. $proc = Start-Process -FilePath 'regsvr32.exe' -ArgumentList "/s /u `"$path`"" -PassThru -Wait -WindowStyle Hidden
  55. if ($proc.ExitCode -ne 0) {
  56. Write-Warning "regsvr32 /u reported exit $($proc.ExitCode) for $path; verifying registry state directly"
  57. }
  58. Remove-ProjectComponent -ProgId $component.ProgId -ClassId $component.ClassId
  59. }
  60. Write-Output "All WSC-MVC components unregistered."

Powered by TurnKey Linux.