Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIX installer: Allow update to new version when gsudo is active. #203

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 36 additions & 10 deletions src/gsudo.Installer/Product.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
<Product Id="*" Name="gsudo v$(env.version)" Language="1033" Version="$(env.version_MajorMinorPatch)"
UpgradeCode="567b5616-d362-484e-b6ff-7c1875cf0aee" Manufacturer="gerardog">

<Package InstallerVersion="200"
<Package InstallerVersion="200"
Compressed="yes"
InstallScope="perMachine"
Manufacturer="Gerardo Grignoli"
Description="gsudo is a sudo-equivalent for windows" />

<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate EmbedCab="yes" />

Expand Down Expand Up @@ -38,9 +38,14 @@
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />

<InstallExecuteSequence>
<!-- https://stackoverflow.com/a/17608049/97471 -->
<Custom Action="CreateSudoExeLink" Before="InstallFinalize">NOT Installed</Custom>
<Custom Action="RemoveSudoExeLink" After="InstallInitialize">Installed AND NOT REINSTALL</Custom>
</InstallExecuteSequence>
<Custom Action="CreateSudoCurrentFolderLink" Before="InstallFinalize">NOT Installed</Custom>
<Custom Action="RemoveSudoCurrentFolderLink" After="InstallInitialize">Installed AND NOT REINSTALL</Custom>

<Custom Action="RemoveInstallFolder" After="InstallInitialize">REMOVE AND NOT UPGRADINGPRODUCTCODE</Custom>
</InstallExecuteSequence>

</Product>

Expand All @@ -58,21 +63,22 @@
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="gsudo">
<Directory Id="VERSIONFOLDER" Name="$(env.version)">

<Component Id="GSudoPath" Guid="923f225a-75cd-4fca-ad48-a4161187f7a4">
<CreateFolder />
<Environment Id="SET_ENV" Action="set" Name="PATH" Part="last" Permanent="no" System="yes"
Value="[INSTALLFOLDER]" />
Value="[INSTALLFOLDER]Current" />
</Component>

<Component Id="GSudoExe" Guid="bec137e1-06e2-4efb-aea9-30306cc01c87">
<Component Id="GSudoExe" Guid="">
<Condition>
<![CDATA[VersionNT64]]>
</Condition>
<File Id="GSudoExe" KeyPath="yes" Name="gsudo.exe" Source="..\..\artifacts\x64\gsudo.exe"/>
</Component>

<Component Id="GSudoExeX86" Guid="bec137e1-06e2-4efb-aea9-30306cc01c86">
<Component Id="GSudoExeX86" Guid="">
<Condition>
<![CDATA[NOT(VersionNT64)]]>
</Condition>
Expand All @@ -88,25 +94,45 @@
<File Id="GSudoModule" KeyPath="yes" Name="gsudoModule.psm1" Source="..\..\artifacts\x64\gsudoModule.psm1" />
<File Id="InvokeGSudo" KeyPath="no" Name="invoke-gsudo.ps1" Source="..\..\artifacts\x64\invoke-gsudo.ps1" />
</Component>


</Directory>
</Directory>
</Directory>
</Directory>
</Fragment>

<Fragment>
<CustomAction Id="CreateSudoExeLink"
Directory="INSTALLFOLDER"
ExeCommand='cmd /c mklink sudo.exe "[INSTALLFOLDER]gsudo.exe"'
Directory="VERSIONFOLDER"
ExeCommand='cmd /c mklink sudo.exe "[VERSIONFOLDER]gsudo.exe"'
Execute="deferred"
Return="ignore"
Impersonate="no" />
<CustomAction Id="RemoveSudoExeLink"
Directory="INSTALLFOLDER"
Directory="VERSIONFOLDER"
ExeCommand='cmd /c DEL sudo.exe'
Execute="deferred"
Return="ignore"
Impersonate="no" />

<CustomAction Id="CreateSudoCurrentFolderLink"
Directory="INSTALLFOLDER"
ExeCommand='cmd /c mklink /D "[INSTALLFOLDER]Current" "[VERSIONFOLDER]"'
Execute="deferred"
Return="ignore"
Impersonate="no" />
<CustomAction Id="RemoveSudoCurrentFolderLink"
Directory="INSTALLFOLDER"
ExeCommand='cmd /c RD /S /Q "[INSTALLFOLDER]Current"'
Execute="deferred"
Return="ignore"
Impersonate="no" />
<CustomAction Id="RemoveInstallFolder"
Directory="INSTALLFOLDER"
ExeCommand='cmd /c RD /S /Q "[INSTALLFOLDER]"'
Execute="deferred"
Return="ignore"
Impersonate="no" />
</Fragment>

</Wix>