microsoft / winget-create

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

[NestedPortable] wingetcreate fails to parse package #354

Closed mdanish-kh closed 1 year ago

mdanish-kh commented 1 year ago

Brief description

As reported in microsoft/winget-pkgs#100719, there appears to be a number of nested portable installers that wingetcreate is failing to parse.

Steps to reproduce

Run

wingetcreate new https://github.com/fujiapple852/trippy/releases/download/0.7.0/trippy-0.7.0-x86_64-pc-windows-msvc.zip

Output

Downloading and parsing: https://github.com/fujiapple852/trippy/releases/download/0.7.0/trippy-0.7.0-x86_64-pc-windows-msvc.zip...
Failed to parse the package from [https://github.com/fujiapple852/trippy/releases/download/0.7.0/trippy-0.7.0-x86_64-pc-windows-msvc.zip]

Some other examples with the same outcome from the winget-pkgs repo:

Examples of nested portables that wingetcreate parses successfully from the winget-pkgs repo:

Some Debug Info

I tried to do a little big of debugging by building the client to see the error cause. I hope it's helpful info.

From the caller https://github.com/microsoft/winget-create/blob/2674058624005df4721080a369b23d1806cb6ee0/src/WingetCreateCore/Common/PackageParser.cs#L497

the execution fails in ParseExeInstallerType() at rc.LoadFrom(path) https://github.com/microsoft/winget-create/blob/2674058624005df4721080a369b23d1806cb6ee0/src/WingetCreateCore/Common/PackageParser.cs#L683

with Win32Exception Message = "The specified image file did not contain a resource section." NativeErrorCode = 1812

Since there isn't an explicit catch block for this exception, we return false with PackageParsing_Error

https://github.com/microsoft/winget-create/blob/2674058624005df4721080a369b23d1806cb6ee0/src/WingetCreateCore/Common/PackageParser.cs#L707-L718

https://github.com/microsoft/winget-create/blob/2674058624005df4721080a369b23d1806cb6ee0/src/WingetCreateCLI/Commands/NewCommand.cs#L201-L205

The code is external from Vestris.ResourceLib, and I could not find the .pdb file for the 2.1.0 version to debug it further. Because of being external, I think adding an explicit catch block for this error should be the fix here.

Environment

Windows Package Manager Manifest Creator v1.2.5.0

Copyright (c) Microsoft Corporation. All rights reserved.

The manifest creation command line utility generates manifest for submitting
apps to the Windows Package Manager repo.

  new         Launches a series of questions to help generate a new manifest
  update      Updates fields of an existing manifest
  submit      Submits a valid manifest directly to the Windows Package Manager repo
  settings    Open settings
  token       Modifies the GitHub auth token cache
  cache       Manage downloaded installers stored in cache

More help can be found at: https://aka.ms/winget-create
Privacy statement: https://aka.ms/privacy