winget-cli

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

action.yml (2385B)


      1 name: Install WinGet
      2 
      3 description: Installs WinGet from sources, caching the installation files if possible
      4 
      5 inputs:
      6   winget-installation-cache:
      7     description: 'Where the installation files will be cached'
      8     required: false
      9     default: 'winget-installation-cache'
     10 
     11 runs:
     12   using: "composite"
     13 
     14   steps:
     15     - name: Cache WinGet installation
     16       id: cache-winget-installation
     17       uses: actions/cache@v4
     18       with:
     19         path: winget-installation-cache
     20         key: winget-installation
     21 
     22     # Winget is not available in the windows-latest image as it is Windows Server 2022 and winget is not yet available officially for it.
     23     # We can still install it in "experimental" mode manually though.
     24     - name: Install WinGet
     25       shell: pwsh
     26       run: |
     27         # Check it doesn't exist to avoid installing it without need
     28         if (!(Get-Command 'winget.exe' -CommandType Application -ErrorAction SilentlyContinue))
     29         {
     30           New-Item -ItemType Directory ${{ inputs.winget-installation-cache }} -Force | Out-Null
     31           Set-Location ${{ inputs.winget-installation-cache }}
     32           $ProgressPreference = "silentlyContinue"
     33           $WingetInstaller = "Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle"
     34           if (!(Test-Path $WingetInstaller))
     35           {
     36             Write-Host "Downloading Winget"
     37             Invoke-WebRequest -Uri https://github.com/microsoft/winget-cli/releases/download/v1.7.10582/$WingetInstaller -OutFile $WingetInstaller
     38           }
     39           $VCLibsInstaller = "Microsoft.VCLibs.x64.14.00.Desktop.appx"
     40           if (!(Test-Path $VCLibsInstaller))
     41           {
     42             Write-Host "Downloading Winget dependency VCLibs"
     43             Invoke-WebRequest -Uri https://aka.ms/$VCLibsInstaller -OutFile $VCLibsInstaller
     44           }
     45           $XamlInstaller = "Microsoft.UI.Xaml.2.8.x64.appx"
     46           if (!(Test-Path $XamlInstaller))
     47           {
     48             Write-Host "Downloading Winget dependency Xaml"
     49             Invoke-WebRequest -Uri https://github.com/microsoft/microsoft-ui-xaml/releases/download/v2.8.6/$XamlInstaller -OutFile $XamlInstaller
     50           }
     51 
     52           Import-Module -Name Appx -UseWindowsPowershell | Out-Null
     53           Add-AppxPackage $VCLibsInstaller
     54           Add-AppxPackage $XamlInstaller
     55           Add-AppxPackage $WingetInstaller
     56         }