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

Update MSI installer to prevent upgrades and not partially remove Chocolatey #3290

Merged
merged 3 commits into from
Aug 2, 2023

Conversation

corbob
Copy link
Member

@corbob corbob commented Jul 31, 2023

Description Of Changes

Update the MSI settings to prevent an upgrade, and to not remove the Chocolatey files.

Motivation and Context

If you try to upgrade Chocolatey using the MSI with an already installed MSI, the upgrade was attempting to uninstall the old Chocolatey, and did not actually upgrade to the new Chocolatey.

Testing

  1. Build the PR and grab the MSI from the Artifacts directory
  2. Using the build MSI perform two phases of testing:

MSI Uninstall testing

  1. Install Chocolatey CLI from the built MSI
  2. Ensure that Chocolatey works (run choco --version --allow-unofficial)
  3. Uninstall Chocolatey CLI from the Add/Remove Programs control panel
  4. Ensure that Chocolatey still works (run choco --version --allow-unofficial)

Upgrade testing

  1. Install Chocolatey CLI 2.2.0 through the MSI
  2. Attempt to upgrade Chocolatey CLI using the built MSI
  3. Ensure that you get an alert indicating upgrade failure and that you must use Chocolatey to upgrade.
  4. From an elevated cmd.exe run: start /wait msiexec /i <path to MSI> /norestart /quiet
  5. Ensure that msiexec exits with 1603 (echo %errorlevel%)

Winget output tests

I have built a custom manifest looking to an internal server, and confirmed that it generates a log file. The log file when I ran it came out like this:

Details

=== Logging started: 8/1/2023  19:59:20 ===
Action start 19:59:20: INSTALL.
Action start 19:59:20: FindRelatedProducts.
Action ended 19:59:20: FindRelatedProducts. Return value 1.
Action start 19:59:20: AppSearch.
Action ended 19:59:21: AppSearch. Return value 1.
Action start 19:59:21: SetWIX_IS_NETFRAMEWORK_48_OR_LATER_INSTALLED.
Action ended 19:59:21: SetWIX_IS_NETFRAMEWORK_48_OR_LATER_INSTALLED. Return value 1.
Action start 19:59:21: SetCHOCOLATEY_INSTALL.
Action ended 19:59:21: SetCHOCOLATEY_INSTALL. Return value 1.
Action start 19:59:21: LaunchConditions.
MSI (s) (BC:AC) [19:59:21:026]: Product: Chocolatey (Install Only) -- UPGRADE FAILURE: Chocolatey CLI cannot be upgraded via the MSI. Please run 'choco upgrade chocolatey' from an elevated terminal window.

UPGRADE FAILURE: Chocolatey CLI cannot be upgraded via the MSI. Please run 'choco upgrade chocolatey' from an elevated terminal window.
Action ended 19:59:21: LaunchConditions. Return value 3.
Action ended 19:59:21: INSTALL. Return value 3.
Property(S): UpgradeCode = {62FC4E65-47F0-488A-B841-ECA07E98A58B}
Property(S): WIXNETFX4RELEASEINSTALLED = #528449
Property(S): WixUIRMOption = UseRM
Property(S): ALLUSERS = 1
Property(S): ARPNOMODIFY = yes
Property(S): ARPNOREPAIR = yes
Property(S): CHOCOLATEY_INSTALL = C:\ProgramData\chocolatey
Property(S): WIX_IS_NETFRAMEWORK_48_OR_LATER_INSTALLED = 1
Property(S): CommonAppDataFolder = C:\ProgramData\
Property(S): TempFolder = C:\Users\vagrant\AppData\Local\Temp\
Property(S): ARPPRODUCTICON = chocolatey.ico
Property(S): Manufacturer = Chocolatey Software, Inc.
Property(S): ProductCode = {7CDB0143-A52F-41CC-84E5-144A611DB90F}
Property(S): ProductLanguage = 1033
Property(S): ProductName = Chocolatey (Install Only)
Property(S): ProductVersion = 2.3.0.0
Property(S): DefaultUIFont = WixUI_Font_Normal
Property(S): WixUI_Mode = FeatureTree
Property(S): ErrorDialog = ErrorDlg
Property(S): SecureCustomProperties = ARPNOMODIFY;ARPNOREPAIR;WIX_DOWNGRADE_DETECTED;WIX_IS_NETFRAMEWORK_48_OR_LATER_INSTALLED;WIX_UPGRADE_DETECTED;WIXNETFX4RELEASEINSTALLED
Property(S): WIX_UPGRADE_DETECTED = {74BA786B-0575-492D-953E-73517F464A5C}
Property(S): MsiLogFileLocation = C:\Users\vagrant\AppData\Local\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\DiagOutputDir\WinGet-Chocolatey.Chocolatey.2.3.0.0-2023-08-01-19-59-19.396.log
Property(S): PackageCode = {F0BA8DEA-132A-45E6-9865-6A7F1FC642D0}
Property(S): ProductState = -1
Property(S): PackagecodeChanging = 1
Property(S): REBOOTPROMPT = S
Property(S): REBOOT = ReallySuppress
Property(S): CURRENTDIRECTORY = C:\packages\winget
Property(S): CLIENTUILEVEL = 2
Property(S): CLIENTPROCESSID = 9088
Property(S): MsiRestartManagerSessionKey = a8ecf4df2e343f46b72f091419e03a5b
Property(S): VersionDatabase = 200
Property(S): VersionMsi = 5.00
Property(S): VersionNT = 603
Property(S): VersionNT64 = 603
Property(S): WindowsBuild = 9600
Property(S): ServicePackLevel = 0
Property(S): ServicePackLevelMinor = 0
Property(S): MsiNTProductType = 1
Property(S): WindowsFolder = C:\Windows\
Property(S): WindowsVolume = C:\
Property(S): System64Folder = C:\Windows\system32\
Property(S): SystemFolder = C:\Windows\SysWOW64\
Property(S): RemoteAdminTS = 1
Property(S): ProgramFilesFolder = C:\Program Files (x86)\
Property(S): CommonFilesFolder = C:\Program Files (x86)\Common Files\
Property(S): ProgramFiles64Folder = C:\Program Files\
Property(S): CommonFiles64Folder = C:\Program Files\Common Files\
Property(S): AppDataFolder = C:\Users\vagrant\AppData\Roaming\
Property(S): FavoritesFolder = C:\Users\vagrant\Favorites\
Property(S): NetHoodFolder = C:\Users\vagrant\AppData\Roaming\Microsoft\Windows\Network Shortcuts\
Property(S): PersonalFolder = C:\Users\vagrant\Documents\
Property(S): PrintHoodFolder = C:\Users\vagrant\AppData\Roaming\Microsoft\Windows\Printer Shortcuts\
Property(S): RecentFolder = C:\Users\vagrant\AppData\Roaming\Microsoft\Windows\Recent\
Property(S): SendToFolder = C:\Users\vagrant\AppData\Roaming\Microsoft\Windows\SendTo\
Property(S): TemplateFolder = C:\ProgramData\Microsoft\Windows\Templates\
Property(S): LocalAppDataFolder = C:\Users\vagrant\AppData\Local\
Property(S): MyPicturesFolder = C:\Users\vagrant\Pictures\
Property(S): AdminToolsFolder = C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Administrative Tools\
Property(S): StartupFolder = C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\
Property(S): ProgramMenuFolder = C:\ProgramData\Microsoft\Windows\Start Menu\Programs\
Property(S): StartMenuFolder = C:\ProgramData\Microsoft\Windows\Start Menu\
Property(S): DesktopFolder = C:\Users\Public\Desktop\
Property(S): FontsFolder = C:\Windows\Fonts\
Property(S): GPTSupport = 1
Property(S): OLEAdvtSupport = 1
Property(S): ShellAdvtSupport = 1
Property(S): MsiAMD64 = 6
Property(S): Msix64 = 6
Property(S): Intel = 6
Property(S): PhysicalMemory = 8192
Property(S): VirtualMemory = 7441
Property(S): AdminUser = 1
Property(S): MsiTrueAdminUser = 1
Property(S): LogonUser = vagrant
Property(S): UserSID = S-1-5-21-69563438-635233097-911806197-1000
Property(S): UserLanguageID = 1033
Property(S): ComputerName = WINDOWS11
Property(S): SystemLanguageID = 1033
Property(S): ScreenX = 1024
Property(S): ScreenY = 768
Property(S): CaptionHeight = 19
Property(S): BorderTop = 1
Property(S): BorderSide = 1
Property(S): TextHeight = 16
Property(S): TextInternalLeading = 3
Property(S): ColorBits = 32
Property(S): TTCSupport = 1
Property(S): Time = 19:59:21
Property(S): Date = 8/1/2023
Property(S): MsiNetAssemblySupport = 4.8.4161.0
Property(S): MsiWin32AssemblySupport = 6.3.22000.1761
Property(S): RedirectedDllSupport = 2
Property(S): MsiRunningElevated = 1
Property(S): Privileged = 1
Property(S): COMPANYNAME = Vagrant
Property(S): DATABASE = C:\Windows\Installer\1381b9.msi
Property(S): OriginalDatabase = C:\Users\vagrant\AppData\Local\Temp\WinGet\Chocolatey.Chocolatey.2.3.0.0\chocolatey-2.3.0.0.msi
Property(S): UILevel = 3
Property(S): MsiUIProgressOnly = 1
Property(S): MsiUIHideCancel = 1
Property(S): ACTION = INSTALL
Property(S): MIGRATE = {74BA786B-0575-492D-953E-73517F464A5C}
MSI (s) (BC:AC) [19:59:21:130]: Product: Chocolatey (Install Only) -- Installation failed.

MSI (s) (BC:AC) [19:59:21:130]: Windows Installer installed the product. Product Name: Chocolatey (Install Only). Product Version: 2.3.0.0. Product Language: 1033. Manufacturer: Chocolatey Software, Inc.. Installation success or error status: 1603.

=== Logging stopped: 8/1/2023  19:59:21 ===

This is the display when manually running the MSI:
2023-08-01_20-04-28

Operating Systems Testing

Windows 11

Change Types Made

  • Bug fix (non-breaking change).
  • Feature / Enhancement (non-breaking change).
  • Breaking change (fix or feature that could cause existing functionality to change).
  • Documentation changes.
  • PowerShell code changes.

Change Checklist

  • Requires a change to the documentation.
  • Documentation has been updated.
  • Tests to cover my changes, have been added.
  • All new and existing tests passed?
  • PowerShell code changes: PowerShell v2 compatibility checked?

Related Issue

Fixes #3286

gep13
gep13 previously requested changes Aug 1, 2023
recipe.cake Outdated Show resolved Hide resolved
recipe.cake Outdated Show resolved Hide resolved
Copy link
Member

@pauby pauby left a comment

Choose a reason for hiding this comment

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

Note, I've only reviewed the chocolatey.en-us.wxl file.

src/chocolatey.install/chocolatey.en-us.wxl Outdated Show resolved Hide resolved
src/chocolatey.install/chocolatey.en-us.wxl Outdated Show resolved Hide resolved
Comment on lines -26 to -29
<CustomAction Id="SetHelpersDirectoryPath" Property="HelpersDirectoryPath" Value="[INSTALLDIR]\\helpers" />
<CustomAction Id="SetRedirectsDirectoryPath" Property="RedirectsDirectoryPath" Value="[INSTALLDIR]\\redirects" />
<CustomAction Id="SetToolsDirectoryPath" Property="ToolsDirectoryPath" Value="[INSTALLDIR]\\tools" />

Copy link
Member

Choose a reason for hiding this comment

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

Why are you removing these custom actions?

I was under the impression they are required to be available?

Copy link
Member Author

Choose a reason for hiding this comment

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

These custom actions only fire when Chocolatey is already installed, which only happens on an upgrade, change, repair, or uninstall. None of which we currently do anything with.

Comment on lines -45 to -48
<!-- Set these values during the uninstall such that we can remove the folders -->
<Custom Action="SetHelpersDirectoryPath" Before="CostInitialize"><![CDATA[Installed]]></Custom>
<Custom Action="SetRedirectsDirectoryPath" Before="CostInitialize"><![CDATA[Installed]]></Custom>
<Custom Action="SetToolsDirectoryPath" Before="CostInitialize"><![CDATA[Installed]]></Custom>
Copy link
Member

Choose a reason for hiding this comment

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

Same as above.

Copy link
Member Author

Choose a reason for hiding this comment

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

These custom actions only fire when Chocolatey is already installed, which only happens on an upgrade, change, repair, or uninstall. None of which we currently do anything with.

Comment on lines -57 to -64
<RemoveFile Id="ChocoEXE" On="uninstall" Name="choco.exe" />
<RemoveFile Id="ChocoIgnore" On="uninstall" Name="choco.exe.ignore" />
<RemoveFile Id="ChocoManifest" On="uninstall" Name="choco.exe.manifest" />
<RemoveFile Id="ChocoCredits" On="uninstall" Name="CREDITS.txt" />
<RemoveFile Id="ChocoLicense" On="uninstall" Name="LICENSE.txt" />
<util:RemoveFolderEx Id="HelpersDirectory" On="uninstall" Property="HelpersDirectoryPath" />
<util:RemoveFolderEx Id="RedirectsDirectory" On="uninstall" Property="RedirectsDirectoryPath" />
<util:RemoveFolderEx Id="ToolsDirectory" On="uninstall" Property="ToolsDirectoryPath" />
Copy link
Member

Choose a reason for hiding this comment

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

So we intend to remove the support to uninstall Chocolatey CLI through the MSI?

Or mainly making it a no-op?

Copy link
Member

@pauby pauby Aug 2, 2023

Choose a reason for hiding this comment

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

It should be a no-op. The goal is to remove from Programs and Features but not actually remove Chocolatey itself in this version. We should notify the user to that @corbob ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, in this version we're going to make it a no-op since the previous behaviour doesn't actually remove all of Chocolatey, and instead leaves it in a broken state that doesn't allow reinstallation without manual intervention. I'll be doing up an ADR for this with the reasoning and options considered. The main reason to do a no-op right now is we would rather have a non operative uninstall than one that isn't working and don't want to rush the work of having a proper uninstall.

With regards to notifying the user @pauby, I wasn't finding anything in my searching about changing things, but I just noticed some things in this diff that I think can work, so I'll look into that.

@corbob corbob marked this pull request as ready for review August 2, 2023 15:59
Copy link
Member

@pauby pauby left a comment

Choose a reason for hiding this comment

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

Just two small changes Cory. If the typo with the missing full stop wasn't there I wouldn't have asked for the other one. So technically this isn't my fault 😄

src/chocolatey.install/chocolatey.en-us.wxl Outdated Show resolved Hide resolved
src/chocolatey.install/chocolatey.en-us.wxl Outdated Show resolved Hide resolved
@gep13
Copy link
Member

gep13 commented Aug 2, 2023

@corbob this will need targeted to the hotfix branch before we can merge.

pauby
pauby previously approved these changes Aug 2, 2023
@pauby
Copy link
Member

pauby commented Aug 2, 2023

Thanks @corbob. Approved this now.

<String Id="RequiresDotNet48" Overridable="yes">Chocolatey CLI application requires .NET Framework 4.8. Please install the .NET Framework then run this installer again.</String>
Copy link
Member

Choose a reason for hiding this comment

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

The wording seems a little off here, shouldn't this be:

Suggested change
<String Id="RequiresDotNet48" Overridable="yes">Chocolatey CLI application requires .NET Framework 4.8. Please install the .NET Framework then run this installer again.</String>
<String Id="RequiresDotNet48" Overridable="yes">Chocolatey CLI requires .NET Framework 4.8. Please install the .NET Framework then run this installer again.</String>

Copy link
Member

Choose a reason for hiding this comment

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

Good catch. I had that above but didn't notice it had been missed.

Copy link
Member Author

Choose a reason for hiding this comment

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

Apologies, fi thought I had copy/pasted the message from the suggestion, but it seems I didn't. I've updated this now.

The MSI previously included logic to remove *some* Chocolatey files.
This would leave Chocolatey in a broken state, but not actually removed.
This commit removes the entries from the MSI, so an "uninstall" of the
MSI is merely a removal of the installer's entry from Add/Remove
Programs.
Currently it's not possible to upgrade Chocolatey with the MSI. This
commit adds functionality to the MSI that will error instead of blindly
allowing an upgrade that doesn't do anything.
@corbob corbob changed the base branch from develop to hotfix/2.2.1 August 2, 2023 17:29
@corbob corbob dismissed gep13’s stale review August 2, 2023 17:32

Changes made/undone.

Copy link
Member

@vexx32 vexx32 left a comment

Choose a reason for hiding this comment

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

Looks good to me, thanks for sorting this out @corbob! 💖

@vexx32 vexx32 merged commit a08464f into chocolatey:hotfix/2.2.1 Aug 2, 2023
3 of 4 checks passed
@corbob corbob deleted the fix-msi branch August 2, 2023 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't find choco.exe after upgrading Chocolatey CLI using the MSI
5 participants