diff --git a/.github/workflows/GA_Close-Inactive-Issues.yml b/.github/workflows/GA_Close-Inactive-Issues.yml index 41e24a15..04314f8d 100644 --- a/.github/workflows/GA_Close-Inactive-Issues.yml +++ b/.github/workflows/GA_Close-Inactive-Issues.yml @@ -12,7 +12,6 @@ jobs: permissions: issues: write pull-requests: write - contents: write steps: - uses: actions/stale@v10.2.0 with: diff --git a/.github/workflows/GA_Mega-linter.yml b/.github/workflows/GA_Mega-linter.yml index 1d3ed2f3..5d2a561e 100644 --- a/.github/workflows/GA_Mega-linter.yml +++ b/.github/workflows/GA_Mega-linter.yml @@ -71,7 +71,7 @@ jobs: - name: Create Pull Request with applied fixes id: cpr if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'pull_request' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix') - uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8.1.0 + uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1 with: token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }} commit-message: "[MegaLinter] Apply linters automatic fixes" diff --git a/.github/workflows/GitFlow_Check-pull-request-source-branch.yml b/.github/workflows/GitFlow_Check-pull-request-source-branch.yml index 7ae6fc3c..0100bb25 100644 --- a/.github/workflows/GitFlow_Check-pull-request-source-branch.yml +++ b/.github/workflows/GitFlow_Check-pull-request-source-branch.yml @@ -59,7 +59,7 @@ jobs: # Step 2: If the branch pattern is invalid, add a label and comment to the PR - name: Handle invalid branch (label + comment) if: failure() - uses: actions/github-script@v8 + uses: actions/github-script@v9 with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | @@ -122,7 +122,7 @@ jobs: # Step 3: If the branch pattern is corrected, remove label and comment - name: Clean up if branch is corrected if: success() - uses: actions/github-script@v8 + uses: actions/github-script@v9 with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | diff --git a/.github/workflows/GitFlow_Create-Release-Branch-and-PR.yaml b/.github/workflows/GitFlow_Create-Release-Branch-and-PR.yaml index 6d6edd2d..f3046b2f 100644 --- a/.github/workflows/GitFlow_Create-Release-Branch-and-PR.yaml +++ b/.github/workflows/GitFlow_Create-Release-Branch-and-PR.yaml @@ -26,7 +26,7 @@ jobs: steps: # Step 1: Calculate the next version number based on the selected increment type - name: Auto Increment Semver Action - uses: MCKanpolat/auto-semver-action@5003b8d37f4b03d95f15303ea10242cbf7c13141 # 2 + uses: MCKanpolat/auto-semver-action@632a84f5d1232fe655c7a85684ba3105c28b3fec # 1.0.11 id: versioning with: github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/GitFlow_Nightly-builds.yml b/.github/workflows/GitFlow_Nightly-builds.yml index 46b7ac33..3c298cfb 100644 --- a/.github/workflows/GitFlow_Nightly-builds.yml +++ b/.github/workflows/GitFlow_Nightly-builds.yml @@ -133,7 +133,7 @@ jobs: # Step 3: Generate new semantic version number - name: Auto Increment Semver Action - uses: MCKanpolat/auto-semver-action@5003b8d37f4b03d95f15303ea10242cbf7c13141 # 2 + uses: MCKanpolat/auto-semver-action@632a84f5d1232fe655c7a85684ba3105c28b3fec # 1.0.11 if: steps.check_prs.outputs.BUILD_NEEDED == 'true' id: versioning with: diff --git a/Sources/Winget-AutoUpdate/Winget-Install.ps1 b/Sources/Winget-AutoUpdate/Winget-Install.ps1 index 15318ba5..504c91c4 100644 --- a/Sources/Winget-AutoUpdate/Winget-Install.ps1 +++ b/Sources/Winget-AutoUpdate/Winget-Install.ps1 @@ -1,11 +1,9 @@ <# .SYNOPSIS Install apps with Winget through Intune or SCCM. -(Can be used standalone.) - Deprecated in favor of Winget-AutoUpdate. .DESCRIPTION Allow to run Winget in System Context to install your apps. -(https://github.com/Romanitho/Winget-Install) - Deprecated in favor of Winget-AutoUpdate. .PARAMETER AppIDs Forward Winget App ID to install. For multiple apps, separate with ",". Case sensitive. @@ -23,6 +21,9 @@ Used to specify logpath. Default is same folder as Winget-Autoupdate project Adds the app to the Winget-AutoUpdate White List. More info: https://github.com/Romanitho/Winget-AutoUpdate If '-Uninstall' is used, it removes the app from WAU White List. +.PARAMETER Source +Specify the WinGet source to use for package operations (for example "winget" or "msstore"). Default is "winget". + .EXAMPLE .\winget-install.ps1 -AppIDs 7zip.7zip @@ -40,6 +41,9 @@ If '-Uninstall' is used, it removes the app from WAU White List. .EXAMPLE .\winget-install.ps1 -AppIDs "Notepad++.Notepad++" -AllowUpgrade + +.EXAMPLE +.\winget-install.ps1 -AppIDs 9WZDNCRFJ3PT -Source msstore #> [CmdletBinding()] @@ -48,7 +52,8 @@ param( [Parameter(Mandatory = $False)] [Switch] $Uninstall, [Parameter(Mandatory = $False)] [String] $LogPath, [Parameter(Mandatory = $False)] [Switch] $WAUWhiteList, - [Parameter(Mandatory = $False)] [Switch] $AllowUpgrade + [Parameter(Mandatory = $False)] [Switch] $AllowUpgrade, + [Parameter(Mandatory = $False)] [String] $Source = "winget" ) @@ -76,7 +81,7 @@ else { #Check if App exists in Winget Repository function Confirm-Exist ($AppID) { #Check is app exists in the winget repository - $WingetApp = & $winget show --Id $AppID -e --accept-source-agreements -s winget | Out-String + $WingetApp = & $winget show --Id $AppID -e --accept-source-agreements -s $Source | Out-String #Return if AppID exists if ($WingetApp -match [regex]::Escape($AppID)) { @@ -139,8 +144,8 @@ function Test-ModsUninstall ($AppID) { } #Install function -function Install-App ($AppID, $AppArgs) { - $IsInstalled = Confirm-Installation $AppID +function Install-App ($AppID, $AppArgs, $Source = 'winget') { + $IsInstalled = Confirm-Installation $AppID -src $Source if (!($IsInstalled) -or $AllowUpgrade ) { #Check if mods exist (or already exist) for preinstall/override/custom/arguments/install/installed $ModsPreInstall, $ModsOverride, $ModsCustom, $ModsArguments, $ModsInstall, $ModsInstalled = Test-ModsInstall $($AppID) @@ -159,21 +164,21 @@ function Install-App ($AppID, $AppArgs) { Write-ToLog "-> Installing $AppID..." "DarkYellow" if ($ModsOverride) { Write-ToLog "-> Arguments (overriding default): $ModsOverride" # Without -h (user overrides default) - $WingetArgs = "install --id $AppID -e --accept-package-agreements --accept-source-agreements -s winget --override $ModsOverride" -split " " + $WingetArgs = @("install", "--id", $AppID, "-e", "--accept-package-agreements", "--accept-source-agreements", "-s", $Source, "--override", $ModsOverride) } elseif ($ModsCustom) { Write-ToLog "-> Arguments (customizing default): $ModsCustom" # With -h (user customizes default) - $WingetArgs = "install --id $AppID -e --accept-package-agreements --accept-source-agreements -s winget -h --custom $ModsCustom" -split " " + $WingetArgs = @("install", "--id", $AppID, "-e", "--accept-package-agreements", "--accept-source-agreements", "-s", $Source, "-h", "--custom", $ModsCustom) } elseif ($ModsArguments -or (-not [string]::IsNullOrWhiteSpace($AppArgs))) { # Prioritize ModsArguments from file over AppArgs from command line $finalArgs = if ($ModsArguments) { $ModsArguments } else { $AppArgs } Write-ToLog "-> Arguments (winget-level): $finalArgs" # Winget parameters with -h $argArray = ConvertTo-WingetArgumentArray $finalArgs - $WingetArgs = @("install", "--id", $AppID, "-e", "--accept-package-agreements", "--accept-source-agreements", "-s", "winget") + $argArray + @("-h") + $WingetArgs = @("install", "--id", $AppID, "-e", "--accept-package-agreements", "--accept-source-agreements", "-s", $Source) + $argArray + @("-h") } else { - $WingetArgs = "install --id $AppID -e --accept-package-agreements --accept-source-agreements -s winget -h" -split " " + $WingetArgs = @("install", "--id", $AppID, "-e", "--accept-package-agreements", "--accept-source-agreements", "-s", $Source, "-h") } Write-ToLog "-> Running: `"$Winget`" $WingetArgs" @@ -185,7 +190,7 @@ function Install-App ($AppID, $AppArgs) { } #Check if install is ok - $IsInstalled = Confirm-Installation $AppID + $IsInstalled = Confirm-Installation $AppID -src $Source if ($IsInstalled) { Write-ToLog "-> $AppID successfully installed." "Green" @@ -209,8 +214,8 @@ function Install-App ($AppID, $AppArgs) { } #Uninstall function -function Uninstall-App ($AppID, $AppArgs) { - $IsInstalled = Confirm-Installation $AppID +function Uninstall-App ($AppID, $AppArgs, $Source = 'winget') { + $IsInstalled = Confirm-Installation $AppID -src $Source if ($IsInstalled) { #Check if mods exist (or already exist) for preuninstall/uninstall/uninstalled $ModsPreUninstall, $ModsUninstall, $ModsUninstalled = Test-ModsUninstall $AppID @@ -244,7 +249,7 @@ function Uninstall-App ($AppID, $AppArgs) { } #Check if uninstall is ok - $IsInstalled = Confirm-Installation $AppID + $IsInstalled = Confirm-Installation $AppID -src $Source if (!($IsInstalled)) { Write-ToLog "-> $AppID successfully uninstalled." "Green" if ($ModsUninstalled) { @@ -399,14 +404,14 @@ if ($Winget) { #Install or Uninstall command if ($Uninstall) { - Uninstall-App $AppID $AppArgs + Uninstall-App $AppID $AppArgs $Source } else { #Check if app exists on Winget Repo $Exists = Confirm-Exist $AppID if ($Exists) { #Install - Install-App $AppID $AppArgs + Install-App $AppID $AppArgs $Source } } diff --git a/Sources/Winget-AutoUpdate/Winget-Upgrade.ps1 b/Sources/Winget-AutoUpdate/Winget-Upgrade.ps1 index 29c5e617..26875b6f 100644 --- a/Sources/Winget-AutoUpdate/Winget-Upgrade.ps1 +++ b/Sources/Winget-AutoUpdate/Winget-Upgrade.ps1 @@ -307,12 +307,12 @@ if (Test-Network) { } #if app is in "include list", update it elseif ($toUpdate -contains $app.Id) { - Update-App $app + Update-App $app -src $Script:WingetSourceCustom } #if app with wildcard is in "include list", update it elseif ($toUpdate | Where-Object { $app.Id -like $_ }) { Write-ToLog "$($app.Name) is wildcard in the include list." - Update-App $app + Update-App $app -src $Script:WingetSourceCustom } #else, skip it else { @@ -338,7 +338,7 @@ if (Test-Network) { } # else, update it else { - Update-App $app + Update-App $app -src $Script:WingetSourceCustom } } } diff --git a/Sources/Winget-AutoUpdate/functions/Confirm-Installation.ps1 b/Sources/Winget-AutoUpdate/functions/Confirm-Installation.ps1 index 0d195b82..eb77ea91 100644 --- a/Sources/Winget-AutoUpdate/functions/Confirm-Installation.ps1 +++ b/Sources/Winget-AutoUpdate/functions/Confirm-Installation.ps1 @@ -8,13 +8,23 @@ .PARAMETER AppVer Expected version prefix. +.PARAMETER src + The WinGet source to query (e.g. "winget", "msstore"). Defaults to + "winget". + .OUTPUTS Boolean: True if installed at version. #> -Function Confirm-Installation ($AppName, $AppVer) { +Function Confirm-Installation ($AppName, $AppVer, $src = "winget") { + if ([string]::IsNullOrWhiteSpace($src)) { + $src = "winget" + } + else { + $src = $src.Trim() + } $JsonFile = "$env:TEMP\InstalledApps.json" - & $Winget export -s winget -o $JsonFile --include-versions | Out-Null + & $Winget export -s $src -o $JsonFile --include-versions | Out-Null $Packages = (Get-Content $JsonFile -Raw | ConvertFrom-Json).Sources.Packages $match = $Packages | Where-Object { $_.PackageIdentifier -eq $AppName -and $_.Version -like "$AppVer*" } diff --git a/Sources/Winget-AutoUpdate/functions/Get-AppInfo.ps1 b/Sources/Winget-AutoUpdate/functions/Get-AppInfo.ps1 index c226725f..ad226ca2 100644 --- a/Sources/Winget-AutoUpdate/functions/Get-AppInfo.ps1 +++ b/Sources/Winget-AutoUpdate/functions/Get-AppInfo.ps1 @@ -9,19 +9,25 @@ .PARAMETER AppID The WinGet package identifier to query. +.PARAMETER src + The WinGet source to query (e.g. "winget", "msstore"). + .OUTPUTS String containing the release notes URL, or empty if not found. .EXAMPLE - $releaseUrl = Get-AppInfo "Microsoft.PowerShell" + $releaseUrl = Get-AppInfo "Microsoft.PowerShell" "winget" .NOTES Uses WinGet show command with source agreements accepted. #> -Function Get-AppInfo ($AppID) { +Function Get-AppInfo ($AppID, $src = 'winget') { + if ([string]::IsNullOrWhiteSpace($src)) { + $src = 'winget' + } # Query WinGet for application details - $String = & $winget show $AppID --accept-source-agreements -s winget | Out-String + $String = & $winget show $AppID --accept-source-agreements -s $src | Out-String # Extract Release Notes URL using regex $ReleaseNote = [regex]::match($String, "(?<=Release Notes Url: )(.*)(?=\n)").Groups[0].Value diff --git a/Sources/Winget-AutoUpdate/functions/Install-Prerequisites.ps1 b/Sources/Winget-AutoUpdate/functions/Install-Prerequisites.ps1 index 5cd9528e..64670b5a 100644 --- a/Sources/Winget-AutoUpdate/functions/Install-Prerequisites.ps1 +++ b/Sources/Winget-AutoUpdate/functions/Install-Prerequisites.ps1 @@ -64,7 +64,7 @@ function Install-Prerequisites { if ($needsInstall) { try { Write-ToLog "Installing VC++ Redistributable ($osArch)..." - $VCRedistUrl = "https://aka.ms/vs/17/release/VC_redist.$osArch.exe" + $VCRedistUrl = "https://aka.ms/vc14/VC_redist.$osArch.exe" $installer = "$env:TEMP\VC_redist.$osArch.exe" Invoke-WebRequest $VCRedistUrl -OutFile $installer -UseBasicParsing diff --git a/Sources/Winget-AutoUpdate/functions/Update-App.ps1 b/Sources/Winget-AutoUpdate/functions/Update-App.ps1 index 0bc8e08d..17251af8 100644 --- a/Sources/Winget-AutoUpdate/functions/Update-App.ps1 +++ b/Sources/Winget-AutoUpdate/functions/Update-App.ps1 @@ -8,12 +8,21 @@ .PARAMETER app PSCustomObject with Name, Id, Version, AvailableVersion properties. + +.PARAMETER src + The WinGet source to use (e.g. 'winget', 'msstore'). Defaults to 'winget'. #> -Function Update-App ($app) { +Function Update-App ($app, $src = "winget") { + if ([string]::IsNullOrWhiteSpace($src)) { + $src = "winget" + } + else { + $src = $src.Trim() + } # Helper function to build winget command parameters function Get-WingetParams ($Command, $ModsOverride, $ModsCustom, $ModsArguments) { - $params = @($Command, "--id", $app.Id, "-e", "--accept-package-agreements", "--accept-source-agreements", "-s", "winget") + $params = @($Command, "--id", $app.Id, "-e", "--accept-package-agreements", "--accept-source-agreements", "-s", $src) if ($Command -eq "install") { $params += "--force" } if ($ModsOverride) { @@ -50,7 +59,7 @@ Function Update-App ($app) { } # Get release notes for notification button - $ReleaseNoteURL = Get-AppInfo $app.Id + $ReleaseNoteURL = Get-AppInfo $app.Id $src $Button1Text = if ($ReleaseNoteURL) { $NotifLocale.local.outputs.output[10].message } else { $null } # Send "updating" notification @@ -80,7 +89,7 @@ Function Update-App ($app) { & $ModsUpgrade } - $ConfirmInstall = Confirm-Installation $app.Id $app.AvailableVersion + $ConfirmInstall = Confirm-Installation $app.Id $app.AvailableVersion $src # Fallback to install if upgrade failed if (-not $ConfirmInstall) { @@ -98,7 +107,7 @@ Function Update-App ($app) { & $ModsInstall } - $ConfirmInstall = Confirm-Installation $app.Id $app.AvailableVersion + $ConfirmInstall = Confirm-Installation $app.Id $app.AvailableVersion $src } } diff --git a/Sources/Winget-AutoUpdate/mods/_Mods-Functions.ps1 b/Sources/Winget-AutoUpdate/mods/_Mods-Functions.ps1 index 9410e680..a660c7c8 100644 --- a/Sources/Winget-AutoUpdate/mods/_Mods-Functions.ps1 +++ b/Sources/Winget-AutoUpdate/mods/_Mods-Functions.ps1 @@ -49,16 +49,16 @@ function Wait-ModsProc ($Wait) { Return } -function Install-WingetID ($WingetIDInst) { +function Install-WingetID ($WingetIDInst, $src = 'winget') { foreach ($app in $WingetIDInst) { - & $Winget install --id $app -e --accept-package-agreements --accept-source-agreements -s winget -h + & $Winget install --id $app -e --accept-package-agreements --accept-source-agreements -s $src -h } Return } -function Uninstall-WingetID ($WingetIDUninst) { +function Uninstall-WingetID ($WingetIDUninst, $src = 'winget') { foreach ($app in $WingetIDUninst) { - & $Winget uninstall --id $app -e --accept-source-agreements -s winget -h + & $Winget uninstall --id $app -e --accept-source-agreements -s $src -h } Return } @@ -188,37 +188,37 @@ function Remove-ModsLnk ($Lnk) { function Add-ProgramsShortcuts ($Shortcuts, $ShortcutsTargets) { $programsPath = "${env:ProgramData}\Microsoft\Windows\Start Menu\Programs" $createdCount = 0 - + # Validate arrays match in length and are not just empty placeholders if ($Shortcuts.Count -ne $ShortcutsTargets.Count -or ($Shortcuts.Count -eq 1 -and [string]::IsNullOrEmpty($Shortcuts[0]))) { Return $createdCount } - + # Create WScript.Shell COM object $WshShell = New-Object -ComObject WScript.Shell -ErrorAction SilentlyContinue if (!$WshShell) { Return $createdCount } - + # Iterate through shortcuts for ($i = 0; $i -lt $Shortcuts.Count; $i++) { $shortcutName = $Shortcuts[$i] $targetPath = $ShortcutsTargets[$i] - + # Skip empty entries if ([string]::IsNullOrEmpty($shortcutName) -or [string]::IsNullOrEmpty($targetPath)) { continue } - + # Construct full shortcut path $shortcutPath = Join-Path $programsPath "$shortcutName.lnk" - + # Create parent directory if it doesn't exist $shortcutDir = Split-Path $shortcutPath -Parent if (!(Test-Path $shortcutDir)) { New-Item -Path $shortcutDir -ItemType Directory -Force -ErrorAction SilentlyContinue | Out-Null } - + # Verify target exists if (Test-Path $targetPath) { # Create shortcut @@ -232,7 +232,7 @@ function Add-ProgramsShortcuts ($Shortcuts, $ShortcutsTargets) { $createdCount++ } } - + Return $createdCount }