microsoft / winget-create

The Windows Package Manager Manifest Creator command-line tool (aka wingetcreate)
MIT License
491 stars 84 forks source link

Multiple nested installers are handled improperly #371

Closed mdanish-kh closed 1 year ago

mdanish-kh commented 1 year ago

Brief description of your issue

The current master build has a very odd behavior in case of multiple nested installers where it prompts for PortableCommandAlias nestedInstallers.Count number of times and creates an incorrect manifest. image

Even if you select separate architecture for each of the nested installer, the final manifest will contain only a single installer because of how winget-create handles nested installers in the code (if you change one property of a nested installer object, it'll get modified in all of them so the final architecture selected by the user will be propagated in all installers)

Steps to reproduce

  1. Select same architecture for all of the nested installers
  2. Select different architectures for all of the nested installers

Examples

From Microsoft.Sysinternals.ZoomIt (3 nested portables all with different architecture)

wingetcreate new https://download.sysinternals.com/files/ZoomIt.zip

From PyPy.PyPy.3.9 (4 nested portables all with same architecture)

wingetcreate new https://downloads.python.org/pypy/pypy3.9-v7.3.11-win64.zip

From yelosan.PH-UKL.TglgQRTY (17 nested installers of different InstallerTypes i.e., portable, MSI)

wingetcreate new https://codeberg.org/attachments/7adf84ee-84a4-41d7-adb0-9f2d4aa979d5

From Git.MinGit (two URLs, same arch for each URL)

wingetcreate new https://github.com/git-for-windows/git/releases/download/v2.40.1.windows.1/MinGit-2.40.1-64-bit.zip https://github.com/git-for-windows/git/releases/download/v2.40.1.windows.1/MinGit-2.40.1-32-bit.zip

Expected behavior

  1. User should be displayed name of nested installer entry in the prompt for Is this a portable package? and should be prompted once about PortableCommandAlias if applicable
  2. If you choose same architecture for any two of the nested portables from same InstallerUrl, the two nested installers should be combined into a single installer node in the manifest as:
- Architecture: <arch>
  InstallerType: zip
  InstallerUrl: <url>
  InstallerHash: <hash>
  NestedInstallerType: portable
  NestedInstallerFiles:
  - RelativeFilePath: <path_to_nested_installer_file1>
  - RelativeFilePath: <path_to_nested_installer_file2>
  1. If you select different architecture, multiple installer nodes should be created

Actual behavior

image

  1. User isn't shown which portable installer winget-create is asking them about and is prompted multiple times for PortableCommandAlias
  2. Manifest created with validation errors.
  3. All nested installers from a single URL have the same arch

Environment

wingetcreate 1.2.5.0 currently does not prompt the user asking to confirm whether the package is portable as it was added in PR #355 so I chose the master build for testing
mdanish-kh commented 1 year ago

Resolved in https://github.com/microsoft/winget-create/pull/372