From fccfa1dd5773242039254e067dcde0cd9fd4fe5e Mon Sep 17 00:00:00 2001 From: Justin Date: Tue, 20 Feb 2024 17:03:10 -0500 Subject: [PATCH] fix(windows-installer): add new cleanup script on install (#824) Issue #, if available: *Description of changes:* - Add new script that runs upon installation to cleanup any dangling Finch VM - This is needed because earlier versions of Finch's Windows installer don't clean up properly on uninstall / reinstall - Even with this change, user's will be prompted to stop limactl on reinstall if Finch is running. Regardless of which action they choose, the install script will cleanup any dangling VMs. *Testing done:* - Tested locally - [x] I've reviewed the guidance in CONTRIBUTING.md #### License Acceptance By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. --------- Signed-off-by: Justin Alvarez --- msi-builder/BuildFinchMSI.ps1 | 1 + msi-builder/FinchMSITemplate.wxs | 5 ++++- msi-builder/removevm.bat | 10 ++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 msi-builder/removevm.bat diff --git a/msi-builder/BuildFinchMSI.ps1 b/msi-builder/BuildFinchMSI.ps1 index 7e3bb52b3..fce453af0 100644 --- a/msi-builder/BuildFinchMSI.ps1 +++ b/msi-builder/BuildFinchMSI.ps1 @@ -60,6 +60,7 @@ Write-Host "Files copied successfully." Write-Host "4. Copy extra scripts, license and icon..." Copy-Item -Path (Join-Path -Path $scriptDirectory -ChildPath "postinstall.bat") -Destination (Join-Path -Path $scriptDirectory -ChildPath "build\Finch") Copy-Item -Path (Join-Path -Path $scriptDirectory -ChildPath "uninstall.bat") -Destination (Join-Path -Path $scriptDirectory -ChildPath "build\Finch") +Copy-Item -Path (Join-Path -Path $scriptDirectory -ChildPath "removevm.bat") -Destination (Join-Path -Path $scriptDirectory -ChildPath "build\Finch") Copy-Item -Path (Join-Path -Path $scriptDirectory -ChildPath "finch.ico") -Destination (Join-Path -Path $scriptDirectory -ChildPath "build\Finch") Copy-Item -Path (Join-Path -Path $scriptDirectory -ChildPath "LICENSE.rtf") -Destination (Join-Path -Path $scriptDirectory -ChildPath "build\Finch") Write-Host "Files copied successfully." diff --git a/msi-builder/FinchMSITemplate.wxs b/msi-builder/FinchMSITemplate.wxs index eb36a4acd..aa1823d17 100644 --- a/msi-builder/FinchMSITemplate.wxs +++ b/msi-builder/FinchMSITemplate.wxs @@ -21,6 +21,7 @@ + @@ -102,9 +103,11 @@ + - NOT Installed + NOT Installed + NOT Installed REMOVE="ALL" diff --git a/msi-builder/removevm.bat b/msi-builder/removevm.bat new file mode 100644 index 000000000..9d595ffbb --- /dev/null +++ b/msi-builder/removevm.bat @@ -0,0 +1,10 @@ +@echo off +SET InstallDir=%~1 + +:: Stop and remove any running instance +finch.exe vm stop -f ^ & +finch.exe vm remove -f ^ & + +:: Just in case +wsl --terminate lima-finch ^ & +wsl --unregister lima-finch