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

Attempt MSI clean-up of ~/.azd/bin #1834

Merged
merged 2 commits into from
Apr 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 13 additions & 2 deletions cli/installer/windows/azd.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
<!-- Make sure any unversioned files including azd.exe (currently) are overwritten on install -->
<Property Id="REINSTALLMODE" Value="amus"/>

<!-- Remove older product(s) early but within the transaction -->
<MajorUpgrade Schedule="afterInstallInitialize" DowngradeErrorMessage="A newer version of !(bind.property.ProductName) is already installed."/>
<!-- Remove older product(s) late but within the transaction to support removing ~\.azd\bin -->
<MajorUpgrade Schedule="afterInstallExecute" DowngradeErrorMessage="A newer version of !(bind.property.ProductName) is already installed."/>

<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="$(var.ProgramFilesFolder)" Name="Program Files">
Expand All @@ -50,6 +50,14 @@
<!-- @Guid will be automatically and durably assigned based on key path -->
<Component Directory="INSTALLDIR">
<File Name="azd.exe"/>

<!--
Attempt to clean up the downloaded files for the current user.
Order matters since removing a folder requires it to be empty; however, Windows Installer makes no guarantees
about order. To improve our chances, insert into the database the corret and lexically sortable order.
-->
<RemoveFile Id="DownloadedFiles" Property="BinFolder" Name="*" On="uninstall"/>
<RemoveFolder Id="DownloadedFolder" Property="BinFolder" On="uninstall"/>
</Component>
<Component Directory="INSTALLDIR">
<File Name="NOTICE.txt"/>
Expand All @@ -76,5 +84,8 @@
<!-- Use customized WixUI_InstallDir that changes the license agreement to just a notice -->
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR"/>
<UIRef Id="AzureDevCLI_InstallDir"/>

<!-- Set the BinFolder property to use for cleaning up downloaded files -->
<SetProperty Id="BinFolder" Value="[%USERPROFILE]\.azd\bin" After="CostFinalize" Sequence="execute"/>
</Product>
</Wix>
33 changes: 31 additions & 2 deletions cli/installer/windows/ui.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<Publish Dialog="BrowseDlg" Control="OK" Event="DoAction" Value="WixUIValidatePath" Order="3">1</Publish>
<Publish Dialog="BrowseDlg" Control="OK" Event="SpawnDialog" Value="InvalidDirDlg" Order="4"><![CDATA[NOT WIXUI_DONTVALIDATEPATH AND WIXUI_INSTALLDIR_VALID<>"1"]]></Publish>

<Publish Dialog="ExitDialog" Control="Finish" Event="EndDialog" Value="Return" Order="999">1</Publish>
<Publish Dialog="ExitDlg" Control="Finish" Event="EndDialog" Value="Return" Order="999">1</Publish>

<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="NoticesDlg">NOT Installed</Publish>
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg">Installed AND PATCH</Publish>
Expand Down Expand Up @@ -75,4 +75,33 @@
</Control>
</Dialog>
</UI>
</Fragment></Wix>
</Fragment>
<Fragment>
<UI>
<Dialog Id="ExitDlg" Width="370" Height="270" Title="!(loc.ExitDialog_Title)">
<Control Id="Finish" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Cancel="yes" Text="!(loc.WixUIFinish)" />
<Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Disabled="yes" Text="!(loc.WixUICancel)" />
<Control Id="Bitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="234" TabSkip="no" Text="!(loc.ExitDialogBitmap)" />
<Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Disabled="yes" Text="!(loc.WixUIBack)" />
<Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
<Control Id="Description" Type="Text" X="135" Y="70" Width="220" Height="40" Transparent="yes" NoPrefix="yes" Text="!(loc.ExitDialogDescription)" />
<Control Id="Title" Type="Text" X="135" Y="20" Width="220" Height="60" Transparent="yes" NoPrefix="yes" Text="!(loc.ExitDialogTitle)" />
<Control Id="UninstallText" Type="Text" X="135" Y="110" Width="220" Height="120" Transparent="yes" NoPrefix="yes" Hidden="yes" Text="The [ProductName] may have downloaded binaries to %USERPROFILE%\.azd\bin and, depending on how azd was used on this machine, may have downloaded binaries to other users' profile directories in their .azd\bin directory. These binaries may need to be removed manually.

To remove such binaries from your home directory, run:

rmdir %USERPROFILE%\.azd\bin.">
<Condition Action="show"><![CDATA[Installed AND REMOVE=ALL]]></Condition>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@barnson any idea why uninstalling via maintenance mode will show this text in the custom ExitDlg (copied from WiX's ExitDialog since I wanted this on uninstall) but not with msiexec /x? The Installed and REMOVE properties are set as I knew they would be so I can't imagine why this doesn't show with msiexec /x.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

</Control>
</Dialog>

<InstallUISequence>
<Show Dialog="ExitDlg" OnExit="success" Overridable="yes" />
</InstallUISequence>

<AdminUISequence>
<Show Dialog="ExitDlg" OnExit="success" Overridable="yes" />
</AdminUISequence>
</UI>
</Fragment>
</Wix>