microsoft / winget-create

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

wingetcreate update confuses argument for --submit in PS script #504

Closed devoptimate closed 5 months ago

devoptimate commented 5 months ago

Brief description of your issue

We're currently trying to get wingetcreate to run in our GitLab CI pipeline. From our CI definition, we call a powershell script, which takes care of preparing a windows environment, installing wingetcreate and - as the last step - calling wingetcreate update.

Instead of targeting our package (Optimate.OptimateSOLIDWORKSPlugin) it tries to target a package called "true"

From the output it seems like a trivial syntax error in the script, but I am unfortunately not an expert of PowerShell programming and can't pinpoint the problem.

Steps to reproduce

We execute the following PowerShell function. Please note the last call to wingetcreate update.

  param(
    [string]$awsS3Bucket,
    [string]$awsS3Region,
    [string]$currentMsi,
    [string]$productVersion,
    [string]$githubAccessToken
  )
  Set-Location ".."
  Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

  # install Visual C++ Redistributable for Visual Studio, .NET 6.0 SDK, Scoop and Wingetcreate
  Invoke-WebRequest -Uri "https://download.visualstudio.microsoft.com/download/pr/9b8baa92-04f4-4b1a-8ccd-aa6bf31592bc/3a25c73326e060e04c119264ba58d0d5/dotnet-sdk-6.0.418-win-x64.exe" -OutFile "dotnet-sdk-6.0.418-win-x64.exe"
  .\dotnet-sdk-6.0.418-win-x64.exe /install /quiet /norestart
  Invoke-WebRequest -Uri "https://aka.ms/highdpimfc2013x64enu" -OutFile "vcredist_x64.exe"
  .\vcredist_x64.exe /install /passive /norestart
  Invoke-Expression "& {$(Invoke-RestMethod get.scoop.sh)} -RunAsAdmin"
  scoop install wingetcreate
  wingetcreate --help | Write-Output
  winget --info | Write-Output

  # submit to winget
  $installerUrl = "https://$awsS3Bucket.s3.$awsS3Region.amazonaws.com/$currentMsi"
  echo "calling wingetcreate..."
  echo "installerUrl: $installerUrl"
  echo "version: $productVersion"
  wingetcreate update `
    --urls $installerUrl `
    --version $productVersion `
    --token $githubAccessToken `
    --submit true `
    --prtitle "Updating Optimate.OptimateSOLIDWORKSPlugin to Version $productVersion" `
    Optimate.OptimateSOLIDWORKSPlugin

Expected behavior

Calling this script with the correct params installs all dependencies required by wingetcreate, installs wingetcreate and uses it to update the package manifest as a PR.

Actual behavior

Upon calling wingetcreate, we get the following output:

Retrieving latest manifest for true
Version 1.0.6 does not exist for true in the Windows Package Manager repository.

Since the only occurrence of true in this command is the argument passed with the --submit flag, I suppose that it comes from there.

Is this a bug, and if not, how can I fix the command and direct it to the manifest of Optimate.OptimateSOLIDWORKSPlugin?

Environment

GitLab shared SaaS Runner
Windows Server 2022
https://docs.gitlab.com/ee/ci/runners/saas/windows_saas_runner.html
https://gitlab.com/gitlab-org/ci-cd/shared-runners/images/gcp/windows-containers/blob/main/cookbooks/preinstalled-software/README.md

[wingetcreate --help]
Telemetry Settings
------------------
The Windows Package Manager Manifest Creator collects usage data in order to improve your experience.
The data is anonymous and collected only by Microsoft.
By default, telemetry is enabled but can be disabled by running `wingetcreate settings` and editing your settings file.
Windows Package Manager Manifest Creator v1.5.7.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.
The following commands are available:
  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
  show        Display a manifest from the Windows Package Manager repository
  info        Displays general info of the tool
More help can be found at: https://aka.ms/winget-create
Privacy statement: https://aka.ms/winget-create-privacy

[winget --info]
winget : The term 'winget' is not recognized as the name of a cmdlet, function, script file, or operable program. 
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
vedantmgoyal9 commented 5 months ago
wingetcreate update Optimate.OptimateSOLIDWORKSPlugin `
    --urls $installerUrl `
    --version $productVersion `
    --token $githubAccessToken `
    --prtitle "Updating Optimate.OptimateSOLIDWORKSPlugin to Version $productVersion" `
    --submit
devoptimate commented 5 months ago

@vedantmgoyal2009 thanks a lot, that worked