From 7c1dc42c77c0d5a899132390cc7aa10b7d3cd1d7 Mon Sep 17 00:00:00 2001 From: Max Horstmann Date: Tue, 29 Apr 2025 10:08:13 -0400 Subject: [PATCH 1/3] add -Mode Silent to Winget task --- Tasks/winget/main.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tasks/winget/main.ps1 b/Tasks/winget/main.ps1 index 002de98..bc293e9 100644 --- a/Tasks/winget/main.ps1 +++ b/Tasks/winget/main.ps1 @@ -373,7 +373,7 @@ else { } $installCommandBlock = { - $installPackageCommand = "Install-WinGetPackage -Scope $($scopeFlagValue) -Source winget -Id '$($Package)' $($versionFlag) | ConvertTo-Json -Depth 10 | Tee-Object -FilePath '$($tempOutFile)'" + $installPackageCommand = "Install-WinGetPackage -Scope $($scopeFlagValue) -Mode Silent -Source winget -Id '$($Package)' $($versionFlag) | ConvertTo-Json -Depth 10 | Tee-Object -FilePath '$($tempOutFile)'" $processCreation = Invoke-CimMethod -ClassName Win32_Process -MethodName Create -Arguments @{CommandLine="C:\Program Files\PowerShell\7\pwsh.exe $($mtaFlag) -Command `"$($installPackageCommand)`""} if (!($processCreation) -or !($processCreation.ProcessId)) { Write-Error "Failed to install package. Process creation failed." From e78f848888bc1eddeb0f5298574a7cefc0a86c61 Mon Sep 17 00:00:00 2001 From: Max Horstmann Date: Tue, 29 Apr 2025 10:10:44 -0400 Subject: [PATCH 2/3] add it to git-clone task as well --- Tasks/git-clone/main.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tasks/git-clone/main.ps1 b/Tasks/git-clone/main.ps1 index 144a9a6..947f84a 100644 --- a/Tasks/git-clone/main.ps1 +++ b/Tasks/git-clone/main.ps1 @@ -296,7 +296,7 @@ function InstallPackage{ $tempOutFile = [System.IO.Path]::GetTempFileName() + ".out.json" $installCommandBlock = { - $installPackageCommand = "Install-WinGetPackage -Scope $($scopeFlagValue) -Source winget -Id $($PackageId) | ConvertTo-Json -Depth 10 | Tee-Object -FilePath '$($tempOutFile)'" + $installPackageCommand = "Install-WinGetPackage -Scope $($scopeFlagValue) -Mode Silent -Source winget -Id $($PackageId) | ConvertTo-Json -Depth 10 | Tee-Object -FilePath '$($tempOutFile)'" $processCreation = Invoke-CimMethod -ClassName Win32_Process -MethodName Create -Arguments @{CommandLine="C:\Program Files\PowerShell\7\pwsh.exe $($mtaFlag) -Command `"$($installPackageCommand)`""} if (!($processCreation) -or !($processCreation.ProcessId)) { Write-Error "Failed to install $PackageId package. Process creation failed." From df9225a047094dc29f666c9559280a0c429207d3 Mon Sep 17 00:00:00 2001 From: Max Horstmann Date: Tue, 29 Apr 2025 10:13:36 -0400 Subject: [PATCH 3/3] also use winget install --silent --- Tasks/git-clone/main.ps1 | 4 ++-- Tasks/winget/main.ps1 | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Tasks/git-clone/main.ps1 b/Tasks/git-clone/main.ps1 index 947f84a..f506c24 100644 --- a/Tasks/git-clone/main.ps1 +++ b/Tasks/git-clone/main.ps1 @@ -266,9 +266,9 @@ function InstallPackage{ # if winget is available, use it to install package if (Get-Command winget -ErrorAction SilentlyContinue) { Write-Host "Installing $PackageId with winget" - winget install --id $PackageId -e --source winget + winget install --id $PackageId -e --source winget --silent $installExitCode = $LASTEXITCODE - Write-Host "'winget install --id $PackageId -e --source winget' exited with code: $($installExitCode)" + Write-Host "'winget install --id $PackageId -e --source winget --silent' exited with code: $($installExitCode)" if ($installExitCode -eq 0) { # add package path to path $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") + ";" + $PackagePath diff --git a/Tasks/winget/main.ps1 b/Tasks/winget/main.ps1 index bc293e9..066c0d1 100644 --- a/Tasks/winget/main.ps1 +++ b/Tasks/winget/main.ps1 @@ -337,7 +337,7 @@ if ($RunAsUser -eq "true") { $versionFlag = "--version `"$($Version)`"" } Write-Host "Appending package install: $($Package)" - AppendToUserScript "winget install --id `"$($Package)`" $($versionFlag) --accept-source-agreements --accept-package-agreements" + AppendToUserScript "winget install --id `"$($Package)`" $($versionFlag) --accept-source-agreements --accept-package-agreements --silent" AppendToUserScript "Write-Host `"winget exit code: `$LASTEXITCODE`"" } # We're running in configuration file mode: