Benutzer-Werkzeuge

Webseiten-Werkzeuge


winget

Dies ist eine alte Version des Dokuments!


Windows Package Manager (winget)

  • Windows Package Manager (winget): Windows Paketverwaltung (Idee die Microsoft von AppGet geklaut hat)
  • winstall: Winget kann entweder ein Paket auf einmal installieren oder mit einer json-Datei mehrere Pakete "importieren". Mit der Webanwendung winstall, kann man schnell und einfach eine Datei für den Import erstellen.
    • winget: Quelle msstore entfernen: winget source remove msstore
    • winget import --ignore-versions -i $env:userprofile/Downloads/winstall-0000.json

Configuration

Pfad zur Konfigurationsdatei: $env:localappdata/Packages/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe/LocalState/settings.json

oder mit dem Befehl öffnen:

> winget settings
settings.json
{
    "$schema": "https://aka.ms/winget-settings.schema.json",
    // For documentation on these settings, see: https://aka.ms/winget-settings
    "experimentalFeatures": {
        "dependencies": true,
        "directMSI": true,
        "experimentalARG": true,
        "experimentalCMD": true
    },
    "installBehavior": {
        "preferences": {
            "locale": [
                "en-US"
            ],
            "scope": "machine"
        },
        "requirements": {}
    },
    "logging": {
        "level": "info"
    },
    "network": {
        "doProgressTimeoutInSeconds": 30,
        "downloader": "wininet"
    },
    "source": {
        "autoUpdateIntervalInMinutes": 5
    },
    "telemetry": {
        "disable": true
    },
    "visual": {
        "progressBar": "accent"
    }
}

Installation

Windows Server

  • Winget wird offiziell nicht auf Windows Server unterstützt.
  • Winget benötigt eigentlich "App Execution Aliases" und kann deshalb nur auf Windows Server 2022 oder neuer ohne Probleme installiert werden
  • Winget läuft nicht auf Windows Server Versionen, die älter sind als 2019 und kann mit einigen Workarounds auf 2019 lauffähig gemacht werden
winget.ps1
$ErrorActionPreference = 'Stop'
 
$info = Get-ComputerInfo -Property @("WindowsInstallationType", "WindowsVersion")
if ($info.WindowsInstallationType -ne "Server") { 
    write-host "This script is only intended for use on Windows Server"
    return
}
 
# Microsoft.UI.Xaml: https://www.nuget.org/packages/Microsoft.UI.Xaml
# Microsoft.VCLibs: https://docs.microsoft.com/troubleshoot/developer/visualstudio/cpp/libraries/c-runtime-packages-desktop-bridge#how-to-install-and-update-desktop-framework-packages
# WinGet: https://github.com/microsoft/winget-cli#manually-update
 
# update links manually
 
$msuixaml = "https://www.nuget.org/api/v2/package/Microsoft.UI.Xaml/2.7.1"
$vclibs = "https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx"
$winget = "https://github.com/microsoft/winget-cli/releases/download/v1.2.10271/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle"
$wingetLicense = "https://github.com/microsoft/winget-cli/releases/download/v1.2.10271/b0a0692da1034339b76dce1c298a1e42_License1.xml"
 
$msuixamlPath = "$env:tmp/microsoft.ui.xaml.zip"
$msuixamlPathExtracted = "$env:tmp/microsoft-ui-xaml"
$vclibsPath = "$env:tmp/Microsoft.VCLibs.Desktop.appx"
$wingetPath = "$env:tmp/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle"
$wingetLicensePath = "$env:tmp/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.license.xml"
 
Invoke-WebRequest -UseBasicParsing -Uri $msuixaml -OutFile $msuixamlPath
Expand-Archive -LiteralPath $msuixamlPath -DestinationPath $msuixamlPathExtracted -Force
$msuixamlExtracted = Get-ChildItem -File -LiteralPath "$msuixamlPathExtracted/tools/AppX/x64/Release" | Where-Object { [regex]::Match($_.Extension, "^\.(appx|msix)(bundle)?$") } | Select-Object -ExpandProperty FullName -First 1
Add-AppxPackage -Path $msuixamlExtracted
 
Invoke-WebRequest -UseBasicParsing -Uri $vclibs -OutFile $vclibsPath
Add-AppxPackage -Path $vclibsPath
 
Invoke-WebRequest -UseBasicParsing -Uri $winget -OutFile $wingetPath
Invoke-WebRequest -UseBasicParsing -Uri $wingetLicense -OutFile $wingetLicensePath
Add-AppxPackage -Path $wingetPath
 
# App Execution Alias workaround for windows server versions older than 2022
if ($info.WindowsVersion -lt 2009) {
    $isDeveloperMode = $false
    $keyDeveloperMode = "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock"
    $valueDeveloperMode = "AllowDevelopmentWithoutDevLicense"
    $isDeveloperMode = 1 -eq (Get-ItemProperty -LiteralPath $keyDeveloperMode -Name $valueDeveloperMode -ErrorAction SilentlyContinue | Select-Object -ExpandProperty AllowDevelopmentWithoutDevLicense)
 
    $installLocation = Get-AppxPackage Microsoft.DesktopAppInstaller | Select-Object -ExpandProperty InstallLocation
    $symlinkValue = "$installLocation/winget.exe"
    $symlinkPath = "$env:USERPROFILE/AppData/Local/Microsoft/WindowsApps/winget.exe"
    $symlink = "New-Item -ItemType SymbolicLink -Value '$symlinkValue' -Path '$symlinkPath' -Force"
 
    if ($isDeveloperMode) {
        Invoke-Expression $symlink
    }
    else {
        if ($IsCoreCLR) {
            $pwsh = "pwsh"
        }
        else {
            $pwsh = "powershell"
        }
 
        Start-Process $pwsh -Verb RunAs -ArgumentList "-NoLogo -NoProfile -Command $symlink" -WindowStyle Hidden
 
        if (Test-Path -PathType Leaf -LiteralPath $symlinkPath) {
            Write-Host "SymbolicLink was successfully created!"
        }
        else {
            Write-Host "Couldn't create SymbolicLink with this command: `"$symlink`""
        }
    }
}
/home/http/wiki/data/attic/winget.1657970284.txt · Zuletzt geändert: von david