Skip to content

Commit

Permalink
Fix MSI upgrage and uninstall flow
Browse files Browse the repository at this point in the history
  • Loading branch information
requilence committed Oct 30, 2018
1 parent 10fcb22 commit a13c90e
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 86 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ goreleaser --snapshot
```

## Build MSI package
– Should be done on Windows machine
– Open command prompt(cmd.exe)
– Go to cagent directory `cd path_to_directory`
– Run `goreleaser --snapshot` to build binaries
– Run `build-win.bat`
Should be done on Windows machine
- [Download go-msi](https://github.com/cloudradar-monitoring/go-msi/releases) and put it in the `C:\Program Files\go-msi`
- Open command prompt(cmd.exe or powershell)
- Go to cagent directory `cd path_to_directory`
- Run `goreleaser --snapshot` to build binaries
- Run `build-win.bat`
23 changes: 23 additions & 0 deletions pkg-scripts/msi-templates/FolderUninstall.wxs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0"?>

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">

<Fragment Id="FolderUninstall">
<?define RegDir="SYSTEM\ControlSet001\services\[Manufacturer]:[ProductName]"?>
<?define RegValueName="InstallDir"?>
<Property Id="INSTALLFOLDER">
<RegistrySearch Root="HKLM" Key="$(var.RegDir)" Type="raw"
Id="APPLICATIONFOLDER_REGSEARCH" Name="$(var.RegValueName)" />
</Property>

<DirectoryRef Id='INSTALLDIR'>
<Component Id="UninstallFolder" Guid="*">
<CreateFolder Directory="INSTALLDIR"/>
<util:RemoveFolderEx Property="INSTALLDIR" On="uninstall"/>
<RemoveFolder Id="INSTALLDIR" On="uninstall"/>
<RegistryValue Root="HKLM" Key="$(var.RegDir)" Name="$(var.RegValueName)"
Type="string" Value="[INSTALLDIR]" KeyPath="yes"/>
</Component>
</DirectoryRef>
</Fragment>
</Wix>
8 changes: 6 additions & 2 deletions pkg-scripts/msi-templates/WixUI_HK.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,19 @@
<Publish Dialog="InstallDirDlg" Control="Next" Event="SetTargetPath" Value="[WIXUI_INSTALLDIR]" Order="1">1</Publish>
<Publish Dialog="InstallDirDlg" Control="Next" Event="DoAction" Value="WixUIValidatePath" Order="2">NOT WIXUI_DONTVALIDATEPATH</Publish>
<Publish Dialog="InstallDirDlg" Control="Next" Event="SpawnDialog" Value="InvalidDirDlg" Order="3"><![CDATA[NOT WIXUI_DONTVALIDATEPATH AND WIXUI_INSTALLDIR_VALID<>"1"]]></Publish>
<Publish Dialog="InstallDirDlg" Control="Next" Event="NewDialog" Value="ConfigDlg_HK" Order="4">WIXUI_DONTVALIDATEPATH OR WIXUI_INSTALLDIR_VALID="1"</Publish>


<Publish Dialog="InstallDirDlg" Control="Next" Event="NewDialog" Order="4" Value="VerifyReadyDlg">OLDERVERSIONBEINGUPGRADED AND WIXUI_INSTALLDIR_VALID="1"</Publish>
<Publish Dialog="InstallDirDlg" Control="Next" Event="NewDialog" Order="5" Value="ConfigDlg_HK">NOT OLDERVERSIONBEINGUPGRADED AND WIXUI_INSTALLDIR_VALID="1"</Publish>
<Publish Dialog="ConfigDlg_HK" Control="Back" Event="NewDialog" Value="InstallDirDlg">1</Publish>
<Publish Dialog="ConfigDlg_HK" Control="Next" Event="NewDialog" Value="VerifyReadyDlg">1</Publish>

<Publish Dialog="InstallDirDlg" Control="ChangeFolder" Property="_BrowseProperty" Value="[WIXUI_INSTALLDIR]" Order="1">1</Publish>
<Publish Dialog="InstallDirDlg" Control="ChangeFolder" Event="SpawnDialog" Value="BrowseDlg" Order="2">1</Publish>

<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Value="MaintenanceTypeDlg" Order="2">Installed</Publish>
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Order="1" Value="InstallDirDlg">OLDERVERSIONBEINGUPGRADED AND WIXUI_INSTALLDIR_VALID="1"</Publish>
<Publish Dialog="VerifyReadyDlg" Control="Back" Event="NewDialog" Order="2" Value="ConfigDlg_HK">NOT OLDERVERSIONBEINGUPGRADED AND WIXUI_INSTALLDIR_VALID="1"</Publish>


<Publish Dialog="MaintenanceWelcomeDlg" Control="Next" Event="NewDialog" Value="MaintenanceTypeDlg">1</Publish>

Expand Down
9 changes: 0 additions & 9 deletions pkg-scripts/msi-templates/choco/LICENSE.txt

This file was deleted.

10 changes: 0 additions & 10 deletions pkg-scripts/msi-templates/choco/VERIFICATION.txt

This file was deleted.

7 changes: 0 additions & 7 deletions pkg-scripts/msi-templates/choco/chocolateyInstall.ps1

This file was deleted.

6 changes: 0 additions & 6 deletions pkg-scripts/msi-templates/choco/chocolateyUninstall.ps1

This file was deleted.

38 changes: 0 additions & 38 deletions pkg-scripts/msi-templates/choco/pkg.nuspec

This file was deleted.

24 changes: 15 additions & 9 deletions pkg-scripts/msi-templates/product.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
Manufacturer="{{.Company}}"
Language="1033">

<Package InstallerVersion="200" Compressed="yes" Comments="Windows Installer Package" InstallScope="perMachine"/>
<Package InstallerVersion="200" Compressed="yes" Comments="Windows Installer Package"/>

<Media Id="1" Cabinet="product.cab" EmbedCab="yes"/>

Expand All @@ -34,18 +34,21 @@
{{if gt (.Files.Items | len) 0}}
<Component Id="ApplicationFiles" Guid="{{.Files.GUID}}">
{{range $i, $e := .Files.Items}}
<File Id="ApplicationFile{{$i}}" Source="{{$e}}"/>
{{if eq $i 0}}
<ServiceInstall Id="ServiceInstaller" Name="Cagent" Type="ownProcess" Vital="yes" DisplayName="Cagent" Description="Cagent" Start="auto" Account="LocalSystem" ErrorControl="normal" Arguments=" /start cagent" Interactive="no" />
<ServiceControl Id="StartService" Name="Cagent" Stop="both" Start="install" Remove="uninstall" Wait="yes" />
{{end}}
{{end}}
<ServiceInstall Id="ServiceInstaller" Name="Cagent" Type="ownProcess" Vital="yes" DisplayName="Cagent" Description="Cagent" Start="auto" Account="LocalSystem" ErrorControl="normal" Interactive="no">
</ServiceInstall>
<ServiceControl Id="StartService" Name="Cagent" Stop="both" Start="install" Remove="uninstall" Wait="yes">
<ServiceArgument />
</ServiceControl>
{{end}}
<File Id="ApplicationFile{{$i}}" Source="{{$e}}"/>
{{end}}
</Component>
{{end}}
{{if gt (.Directories | len) 0}}
{{range $i, $e := .Directories}}
<Directory Id="APPDIR{{$i}}" Name="{{$e}}" />
{{end}}
{{range $i, $e := .Directories}}
<Directory Id="APPDIR{{$i}}" Name="{{$e}}" />
{{end}}
{{end}}
</Directory>
</Directory>
Expand Down Expand Up @@ -137,6 +140,9 @@
{{range $i, $e := .Directories}}
<ComponentGroupRef Id="AppFiles{{$i}}" />
{{end}}
<Feature Id="Uninstall">
<ComponentRef Id="UninstallFolder" Primary="yes"/>
</Feature>
</Feature>

<UI>
Expand Down

0 comments on commit a13c90e

Please sign in to comment.