microsoft / microsoft/winget-cli-restsource

Get-WinGetManifest does not work with .yaml files because it's relying on a missing variable

Open
#179 1 comment 0 reactions 1 assignee View on GitHub

@RDMacLachlan is already working on this.

Since Oct 5, 2022.

Issue-Bug
Dominant language
C#
Stars
317
Forks
79
PR merge metrics
No merged PRs in 30d

Description

Brief description of your issue

Attempting to use Add-WinGetManifest to add a .yaml file. This eventually calls into Get-WinGetManifest. This does a check for $WinGetDesktopAppInstallerLibLoaded which is never set, so this code path will always fail. Working around this requires manually setting a global $WinGetDesktopAppInstallerLibLoaded value before running the cmdlet.

Tip: Using Set-StrictMode -Version Latest in every cmdlet script would help to catch issues like this as it will write an error when trying to reference an unset variable.

Steps to reproduce

Run Add-WinGetManifest and point it to a yaml file:

Add-WinGetManifest -FunctionName xxx -Path d:\path\to\manifest.yaml

Expected behavior

Should work

Actual behavior

Fails:

PS D:\b\winget-cli-restsource-ameltzer\bin> add-wingetmanifest -FunctionName "xxx" -Path D:\path\to\manifest.yaml -Verbose 
[snip]
VERBOSE: Retrieving a copy of the app Manifest file for submission to WinGet source.
VERBOSE: Retrieving the Package Manifest for: D:\path\to\manifest.yaml
VERBOSE: Retrieved content from the manifest (manifest.yaml).
Get-WinGetManifest: D:\b\winget-cli-restsource-ameltzer\bin\Library\Add-WinGetManifest.ps1:109:32
Line |
 109 |          $ApplicationManifest = Get-WinGetManifest -Path $Path
     |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Unable to process YAML files. Re-import the module to reload the required dependencies.

VERBOSE: Returning (0) manifests based on search.
Exception: D:\b\winget-cli-restsource-ameltzer\bin\Library\Add-WinGetManifest.ps1:111:13
Line |
 111 |              throw "Failed to retrieve a proper manifest. Verify and t …
     |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Failed to retrieve a proper manifest. Verify and try again.
Environment
N/A

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.