Repair-WinGetPackageManager outputs noise in PowerShell transcripts #4005
Labels
Issue-Bug
It either shouldn't be doing this or needs an investigation.
PowerShell
Issue related to WinGet PowerShell Module or cmdlet
Milestone
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](https://private-user-images.githubusercontent.com/2039662/292450178-7ce48d98-e2df-43e3-a018-1cf7b3e86807.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjE3NTA5MDgsIm5iZiI6MTcyMTc1MDYwOCwicGF0aCI6Ii8yMDM5NjYyLzI5MjQ1MDE3OC03Y2U0OGQ5OC1lMmRmLTQzZTMtYTAxOC0xY2Y3YjNlODY4MDcucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDcyMyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA3MjNUMTYwMzI4WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9M2NjNTNmZTdhZTI5YTFiNzI5MmZiNmVmZmU4NzYyYjRjOTM5MWVjMDE1ZWQ4MWNjNTY3NTkyMTEwZWJjN2YyYSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.6NG3xbx8OEHVSoRzUuGlKNwTg6a-ecAiTUiE6zi1mQU)
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:
Steps to reproduce
On a machine which does not have WinGet installed, open PowerShell 7 and run the following:
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
The text was updated successfully, but these errors were encountered: