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
22.93k stars 1.42k forks source link

`Get-WinGetConfiguration` can't open a valid WinGet config file #4636

Open o-l-a-v opened 1 month ago

o-l-a-v commented 1 month ago

Brief description of your issue

Steps to reproduce

See description

Expected behavior

Should be able to read a default WinGet config file. Could it be due to JSON with comments?

Actual behavior

Fails.

Environment

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

Windows: Windows.Desktop v10.0.22631.3880
System Architecture: X64
Package: Microsoft.DesktopAppInstaller v1.23.1911.0

Winget Directories                 
-----------------------------------------------------------------------------------------------------------------------
Logs                               %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\Diag
User Settings                      %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\sett
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
ProxyCommandLineOptions                   Disabled
DefaultProxy                              Disabled
mdanish-kh commented 1 month ago

In the context of winget configure command, the winget settings file is not a valid WinGet Configuration file. You can find WinGet configuration samples over at https://aka.ms/dsc.yaml.

An example configuration file to set WinGet user settings would be:

# yaml-language-server: $schema=https://aka.ms/configuration-dsc-schema/0.2
properties:
  resources:
    - resource: Microsoft.WinGet.DSC/WinGetUserSettings
      directives:
        description: Set WinGet user settings
        allowPrerelease: true
      settings:
        Settings:
          network:
            downloader: do
          visual:
            progressBar: rainbow
          $schema: https://aka.ms/winget-settings.schema.json
  configurationVersion: 0.2.0
o-l-a-v commented 1 month ago

Thanks for the info @mdanish-kh. I was looking for info regarding whether the PowerShell module Microsoft.WinGet.Client also requires --accept-source-agreements and --accept-package-agreements on a fresh system, but found no such info or input parameters for Install-WinGetPackage. Which lead me to *-WinGetConfiguration cmdlets.

Found this now:

Maybe it's not dealt with yet. This is alpha/beta after all?

mdanish-kh commented 1 month ago

There is a -Confirm parameter for Install-WinGetPackage but I am not sure if its usage is the same as what you're looking for.

This is alpha/beta after all?

Yes, for now the PowerShell module is intended to be treated as pre-release as written in its description, which is probably why there aren't solid docs for it yet. You would be better off installing the latest version of the module and then running Get-Help <cmdlet> to see all supported options

[comment]: <[Policy] PowerShell> [comment]: <[Policy] Issue-Docs>