winget-cli icon indicating copy to clipboard operation
winget-cli copied to clipboard

Repair-WinGetPackageManager outputs noise in PowerShell transcripts

Open janegilring opened this issue 2 years ago • 0 comments

Brief description of your issue

The log file for the WinGet bootstrapping outputs the following: The term 'winget' is not recognized as a name of a cmdlet, function, script file, or executable program.

This happens even though we don`t call winget.exe directly in the bootstrapping-script, we just run Repair-WinGetPackageManager to install WinGet.

Simple repro on a fresh 2022 VM: image

I suspect this is due to some internal workings of Repair-WinGetPackageManager checking for the existence of winget before installing it if not present.

I`m not too familiar with C# - but seems like the relevant parts are here https://github.com/microsoft/winget-cli/blob/master/src/PowerShell/Microsoft.WinGet.Client.Engine/Commands/WinGetPackageManagerCommand.cs#L91 and here https://github.com/microsoft/winget-cli/blob/master/src/PowerShell/Microsoft.WinGet.Client.Engine/Common/WinGetIntegrity.cs#L98

Suggestions for possible solutions:

  • Add a -Force switch to Repair-WinGetPackageManager to make it skip checking existence of winget.exe
  • Add a separate Install-WinGetPackageManager which can be used for bootstrapping scenarios
  • Suppress the output of the presence of winget.exe

Steps to reproduce

On a machine which does not have WinGet installed, open PowerShell 7 and run the following:

Start-Transcript
Install-Module -Name Microsoft.WinGet.Client
$null = Repair-WinGetPackageManager -AllUsers
Stop-Transcript

Expected behavior

Repair-WinGetPackageManager should not output the following to the PowerShell transcript log file: `The term 'winget' is not recognized as a name of a cmdlet, function, script file, or executable program.

Actual behavior

Repair-WinGetPackageManager outputs the following to the PowerShell transcript log file: `The term 'winget' is not recognized as a name of a cmdlet, function, script file, or executable program.

Environment

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

Windows: Windows.Server v10.0.20348.2159
System Architecture: X64
Package: Microsoft.DesktopAppInstaller v1.21.3421.0

janegilring avatar Dec 22 '23 09:12 janegilring