microsoft / winget-cli

WinGet is the Windows Package Manager. This project includes a CLI (Command Line Interface), PowerShell modules, and a COM (Component Object Model) API (Application Programming Interface).
https://learn.microsoft.com/windows/package-manager/
MIT License
23.02k stars 1.43k forks source link

"maxVersion" is not respected by "winget configure" #4539

Closed akitson-degreed closed 3 months ago

akitson-degreed commented 3 months ago

Brief description of your issue

The winget configured command does not respect the maxVersion parameter in a configuration file.

It works correctly if I use the cli command to do it.

PS> winget install OpenJS.NodeJS -v "18.11.0"
Found an existing package already installed. Trying to upgrade the installed package...
Found Node.js [OpenJS.NodeJS] Version 18.11.0
This application is licensed to you by its owner.
Microsoft is not responsible for, nor does it grant any licenses to, third-party packages.
Downloading https://nodejs.org/dist/v18.11.0/node-v18.11.0-x64.msi
  ██████████████████████████████  29.2 MB / 29.2 MB
Successfully verified installer hash
Starting package install...
Successfully installed

Steps to reproduce

I have the following resource defined in my configuration file:

- resource: Microsoft.WinGet.DSC/WinGetPackage
      id: npm
      directives:
        description: Install Node version 18.11.x
        allowPrerelease: true
        maxVersion: "18.11.0"
      settings:
        id: OpenJS.Nodejs
        source: winget

Expected behavior

I expect it to install a version no higher than 18.11.0.

Actual behavior

When winget configure runs, it installs the latest version.

PS> npm version
{
  npm: '10.7.0',
  node: '22.2.0',
  acorn: '8.11.3',
  ada: '2.7.8',
  ares: '1.28.1',
  base64: '0.5.2',
  brotli: '1.1.0',
  cjs_module_lexer: '1.2.2',
  cldr: '45.0',
  icu: '75.1',
  llhttp: '9.2.1',
  modules: '127',
  napi: '9',
  nghttp2: '1.61.0',
  nghttp3: '0.7.0',
  ngtcp2: '1.3.0',
  openssl: '3.0.13+quic',
  simdjson: '3.9.2',
  simdutf: '5.2.8',
  tz: '2024a',
  undici: '6.13.0',
  unicode: '15.1',
  uv: '1.48.0',
  uvwasi: '0.0.21',
  v8: '12.4.254.14-node.12',
  zlib: '1.3.0.1-motley-7d77fb7'
}

Environment

machine is a fresh VM on Azure

Windows Package Manager v1.7.11261
Copyright (c) Microsoft Corporation. All rights reserved.

Windows: Windows.Desktop v10.0.22621.3593
System Architecture: X64
Package: Microsoft.DesktopAppInstaller v1.22.11261.0

Winget Directories
-------------------------------------------------------------------------------------------------------------------------------
Logs                               %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\DiagOutputDir
User Settings                      %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\settings.json
Portable Links Directory (User)    %LOCALAPPDATA%\Microsoft\WinGet\Links
Portable Links Directory (Machine) C:\Program Files\WinGet\Links
Portable Package Root (User)       %LOCALAPPDATA%\Microsoft\WinGet\Packages
Portable Package Root              C:\Program Files\WinGet\Packages
Portable Package Root (x86)        C:\Program Files (x86)\WinGet\Packages
Installer Downloads                %USERPROFILE%\Downloads

Links
---------------------------------------------------------------------------
Privacy Statement   https://aka.ms/winget-privacy
License Agreement   https://aka.ms/winget-license
Third Party Notices https://aka.ms/winget-3rdPartyNotice
Homepage            https://aka.ms/winget
Windows Store Terms https://www.microsoft.com/en-us/storedocs/terms-of-sale

Admin Setting                             State
--------------------------------------------------
LocalManifestFiles                        Disabled
BypassCertificatePinningForMicrosoftStore Disabled
InstallerHashOverride                     Disabled
LocalArchiveMalwareScanOverride           Disabled
akitson-degreed commented 3 months ago

nevermind.. I figured out I had the version in the wrong place. should be

- resource: Microsoft.WinGet.DSC/WinGetPackage
  id: npm
  directives:
    description: Install Node version 18.10.x
    allowPrerelease: true
  settings:
    id: OpenJS.Nodejs
    source: winget
    version: "18.10.0"