asheroto / winget-install

Install WinGet using PowerShell! Prerequisites automatically installed. Works on Windows 10/11 and Server 2019/2022.
https://bit.ly/winget-install
GNU General Public License v3.0
291 stars 34 forks source link

[Bug]: Nuget error in Powershell 7 #51

Open uffemcev opened 2 hours ago

uffemcev commented 2 hours ago

Checklist

What You Are Seeing?

Hello! :)

I see some error when trying to run the script via PowerShell 7. But when I try PowerShell 5, there is no error and install process goes normal.

System Details

Windows 11 Home 23H2 22631.4317 Admin rights PowerShell 7

Full Output With -Debug

Sorry for Russian in logs, I hope it's not a problem.

Powershell 7 ``` PS C:\Users\uffemcev> &([ScriptBlock]::Create((irm https://raw.githubusercontent.com/asheroto/winget-install/master/winget-install.ps1))) -force -debug winget-install 5.0.1 To check for updates, run winget-install -CheckForUpdate To delay script exit, run winget-install -Wait To force script pausing after execution, run winget-install -NoExit ########## # winget # ########## Installing NuGet package provider... DEBUG: 00:00:00.0000253 Calling SearchForPackages. Name='NuGet' DEBUG: 00:00:00.0011127 PackageProvider::FindPackage with name NuGet DEBUG: 00:00:00.0016058 Calling SearchForPackages After Select 1 Install-PackageProvider: Line | 1019 | … try { Install-PackageProvider -Name NuGet -Force | Out-N … | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | No match was found for the specified search criteria for the provider 'NuGet'. The package provider requires 'PackageManagement' and 'Provider' tags. Please check if the specified package has the tags. Installing Microsoft.WinGet.Client module... Installing winget (this takes a minute or two)... ############ # Complete # ############ winget installed successfully. Checking if winget is installed and working... winget is installed and working. You can go ahead and use it. PS C:\Users\uffemcev> ```
Powershell 5 ``` PS C:\Users\uffemcev> &([ScriptBlock]::Create((irm https://raw.githubusercontent.com/asheroto/winget-install/master/winget-install.ps1))) -force -debug winget-install 5.0.1 To check for updates, run winget-install -CheckForUpdate To delay script exit, run winget-install -Wait To force script pausing after execution, run winget-install -NoExit ########## # winget # ########## Installing NuGet package provider... ОТЛАДКА: 00:00:00.0000911 Trying provider assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\Microsoft.PackageManagement.MsuProvider.dll ОТЛАДКА: 00:00:00.0004580 Trying provider assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\Microsoft.PackageManagement.CoreProviders.dll ОТЛАДКА: 00:00:00.0006223 Trying provider assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\Microsoft.PackageManagement.ArchiverProviders.dll ОТЛАДКА: 00:00:00.0000002 Trying provider assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\Microsoft.PackageManagement.MetaProvider.PowerShell.dll ОТЛАДКА: 00:00:00.0004422 Trying provider assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\Microsoft.PackageManagement.MsiProvider.dll ОТЛАДКА: 00:00:00.0027711 Attempting loading of assembly: C:\Program Files\PackageManagement\ProviderAssemblies\nuget\2.8.5.208\Microsoft.PackageManagement.NuGetProvider.dll ОТЛАДКА: 00:00:00.0028783 Attempting loading of assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\Microsoft.PackageManagement.MsuProvider.dll ОТЛАДКА: 00:00:00.0036677 Attempting loading of assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\Microsoft.PackageManagement.CoreProviders.dll ОТЛАДКА: 00:00:00.0039620 Attempting loading of assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\Microsoft.PackageManagement.MetaProvider.PowerShell.dll ОТЛАДКА: 00:00:00.0040627 Attempting loading of assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\Microsoft.PackageManagement.ArchiverProviders.dll ОТЛАДКА: 00:00:00.0042453 Attempting loading of assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\Microsoft.PackageManagement.MsiProvider.dll ОТЛАДКА: 00:00:00.0054118 Acquiring providers for assemblyC:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\Microsoft.PackageManagement.MetaProvider.PowerShell.dll ОТЛАДКА: 00:00:00.0054128 Acquiring providers for assemblyC:\Program Files\PackageManagement\ProviderAssemblies\nuget\2.8.5.208\Microsoft.PackageManagement.NuGetProvider.dll ОТЛАДКА: 00:00:00.0054394 Acquiring providers for assemblyC:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\Microsoft.PackageManagement.MsuProvider.dll ОТЛАДКА: 00:00:00.0055002 Acquiring providers for assemblyC:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\Microsoft.PackageManagement.CoreProviders.dll ОТЛАДКА: 00:00:00.0055381 Acquiring providers for assemblyC:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\Microsoft.PackageManagement.MsiProvider.dll ОТЛАДКА: 00:00:00.0056428 Acquiring providers for assemblyC:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\Microsoft.PackageManagement.ArchiverProviders.dll ОТЛАДКА: 00:00:00.0360136 Registering providers via metaproviders for assembly Microsoft.PackageManagement.MetaProvider.PowerShell.Internal.PowerShellMetaProvider ОТЛАДКА: 00:00:00.0661508 Initializing provider 'zipfile' ОТЛАДКА: 00:00:00.0662865 Initializing provider 'Programs' ОТЛАДКА: 00:00:00.0663348 Initializing provider 'msu' ОТЛАДКА: 00:00:00.0664803 Initializing provider 'NuGet' ОТЛАДКА: 00:00:00.0666346 Initializing provider 'msi' ОТЛАДКА: 00:00:00.0668723 Initializing provider 'WebDownloader' ОТЛАДКА: 00:00:00.0676306 Initializing provider 'Bootstrap' ОТЛАДКА: 00:00:00.0746578 Trying to register metaprovider ОТЛАДКА: 00:00:00.0797564 Provider 'WebDownloader' Initialized ОТЛАДКА: 00:00:00.0797588 Provider 'zipfile' Initialized ОТЛАДКА: 00:00:00.0797726 Using Downloader Provider WebDownloader ОТЛАДКА: 00:00:00.0797756 Using Archiver Provider zipfile ОТЛАДКА: 00:00:00.0827834 Calling 'Programs::InitializeProvider' ОТЛАДКА: 00:00:00.0827855 Calling 'msu::InitializeProvider' ОТЛАДКА: 00:00:00.1223692 Provider 'Programs' Initialized ОТЛАДКА: 00:00:00.1223692 Provider 'msu' Initialized ОТЛАДКА: 00:00:00.1223965 Using Package Provider Programs ОТЛАДКА: 00:00:00.1224009 Using Package Provider msu ОТЛАДКА: 00:00:00.1280655 Calling 'msi::InitializeProvider' ОТЛАДКА: 00:00:00.1280863 Provider 'msi' Initialized ОТЛАДКА: 00:00:00.1280961 Using Package Provider msi ОТЛАДКА: 00:00:00.1281270 Initialize Bootstrapper ОТЛАДКА: 00:00:00.1282702 Provider 'Bootstrap' Initialized ОТЛАДКА: 00:00:00.1282798 Using Package Provider Bootstrap ОТЛАДКА: 00:00:00.1303824 Initializing PowerShell MetaProvider ОТЛАДКА: 00:00:00.1309158 Calling 'WebDownloader::GetFeatures' ОТЛАДКА: 00:00:00.1311648 Calling 'zipfile::GetFeatures' ОТЛАДКА: 00:00:00.1311843 Calling 'msu::GetFeatures' ОТЛАДКА: 00:00:00.1311971 Calling 'Programs::GetFeatures' ОТЛАДКА: 00:00:00.1318769 The provider 'Programs' is imported ОТЛАДКА: 00:00:00.1319470 The provider 'msu' is imported ОТЛАДКА: 00:00:00.1321382 SUCCESS provider assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\Microsoft.PackageManagement.MsuProvider.dll ОТЛАДКА: 00:00:00.1321801 SUCCESS provider assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\Microsoft.PackageManagement.ArchiverProviders.dll ОТЛАДКА: 00:00:00.1322427 Calling 'NuGet'::'InitializeProvider'. ОТЛАДКА: 00:00:00.1322693 Provider 'NuGet' Initialized ОТЛАДКА: 00:00:00.1322779 Using Package Provider NuGet ОТЛАДКА: 00:00:00.1322743 Calling 'msi::GetFeatures' ОТЛАДКА: 00:00:00.1323442 Calling 'Bootstrap::GetFeatures' ОТЛАДКА: 00:00:00.1324405 The provider 'msi' is imported ОТЛАДКА: 00:00:00.1326274 SUCCESS provider assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\Microsoft.PackageManagement.MsiProvider.dll ОТЛАДКА: 00:00:00.1328289 The provider 'Bootstrap' is imported ОТЛАДКА: 00:00:00.1329526 SUCCESS provider assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\Microsoft.PackageManagement.CoreProviders.dll ОТЛАДКА: 00:00:00.1354764 Calling 'NuGet'::'GetFeatures'. ОТЛАДКА: 00:00:00.1361491 The provider 'NuGet' is imported ОТЛАДКА: 00:00:00.1367379 SUCCESS provider assembly: C:\Program Files\PackageManagement\ProviderAssemblies\nuget\2.8.5.208\Microsoft.PackageManagement.NuGetProvider.dll ОТЛАДКА: 00:00:00.1473473 Calling 'WebDownloader::DownloadFile' 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409','C:\Users\uffemcev\AppData\Local\Temp\Microsoft.PackageMan agement\de2br0bm.xea','40000','False' ОТЛАДКА: 00:00:00.1823451 Attempting to load PowerShell Provider Module [C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1] ОТЛАДКА: 00:00:00.3987723 Загружен поставщик пакетов PowerShell: "[C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1]". ОТЛАДКА: 00:00:00.4036647 Loaded PowerShell Provider: PowerShellGet ОТЛАДКА: 00:00:00.4049474 Initializing provider 'PowerShellGet' ОТЛАДКА: 00:00:00.4096477 Calling New() : MethodName = 'InitializeProvider' ОТЛАДКА: 00:00:00.4096660 Force: True ОТЛАДКА: 00:00:00.4096720 Name: NuGet ОТЛАДКА: 00:00:00.4138653 INVOKING PowerShell Fn Initialize-Provider with args that has length 0 ОТЛАДКА: 00:00:00.4254605 В поставщике PowerShellGet — "Initialize-Provider". ОТЛАДКА: 00:00:00.4255935 Сценарий "PSModule" функции "Initialize-Provider" PowerShell вернул значение null. ОТЛАДКА: 00:00:00.4262481 Done calling powershell «Initialize-Provider» «PSModule» ОТЛАДКА: 00:00:00.4262735 Provider 'PowerShellGet' Initialized ОТЛАДКА: 00:00:00.4262869 Using Package Provider PowerShellGet ОТЛАДКА: 00:00:00.4297354 Calling New() : MethodName = 'GetFeatures' ОТЛАДКА: 00:00:00.4297522 Force: True ОТЛАДКА: 00:00:00.4297608 Name: NuGet ОТЛАДКА: 00:00:00.4301273 INVOKING PowerShell Fn Get-Feature with args that has length 0 ОТЛАДКА: 00:00:00.4348359 В поставщике PowerShellGet — "Get-Feature". ОТЛАДКА: 00:00:00.4407319 Done calling powershell «Get-Feature» «PSModule» ОТЛАДКА: 00:00:00.4407707 The provider 'PowerShellGet' is imported ОТЛАДКА: 00:00:00.4417034 SUCCESS provider assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\Microsoft.PackageManagement.MetaProvider.PowerShell.dll ОТЛАДКА: 00:00:01.0796624 Calling 'WebDownloader::DownloadFile' 'https://onegetcdn.azureedge.net/providers/nuget-2.8.5.208.package.swidtag','C:\Users\uffemcev\AppData\Local\Temp\Micro soft.PackageManagement\kmb0on4n.tzj','40000','False' ОТЛАДКА: 00:00:01.1267436 Calling SearchForPackages. Name='NuGet' ОТЛАДКА: 00:00:01.1349060 PackageProvider::FindPackage with name NuGet ОТЛАДКА: 00:00:01.1355363 Calling SearchForPackages After Select 1 ОТЛАДКА: 00:00:01.1583612 Calling 'WebDownloader::DownloadFile' 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409','C:\Users\uffemcev\AppData\Local\Temp\Microsoft.PackageMan agement\hgikksur.hbo','40000','False' ОТЛАДКА: 00:00:01.1798799 Calling 'WebDownloader::DownloadFile' 'https://onegetcdn.azureedge.net/providers/psl-1.0.0.210.package.swidtag','C:\Users\uffemcev\AppData\Local\Temp\Microso ft.PackageManagement\ofuub5xf.ksg','40000','False' ОТЛАДКА: 00:00:01.3002663 Calling 'WebDownloader::DownloadFile' 'https://onegetcdn.azureedge.net/providers/ChocolateyPrototype-2.8.5.130.package.swidtag','C:\Users\uffemcev\AppData\Lo cal\Temp\Microsoft.PackageManagement\ftbqddlz.ivh','40000','False' ОТЛАДКА: 00:00:01.6356289 Calling 'WebDownloader::DownloadFile' 'https://onegetcdn.azureedge.net/providers/nuget-2.8.5.208.package.swidtag','C:\Users\uffemcev\AppData\Local\Temp\Micro soft.PackageManagement\flqgjjbm.tff','40000','False' ОТЛАДКА: 00:00:01.7542074 Calling 'Bootstrap::GetInstalledPackages' 'nuget','2.8.5.208','','' ОТЛАДКА: 00:00:01.7672078 Calling 'WebDownloader::DownloadFile' 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409','C:\Users\uffemcev\AppData\Local\Temp\Microsoft.PackageMan agement\bb1be31x.l0i','40000','False' ОТЛАДКА: 00:00:01.9652766 Calling 'WebDownloader::DownloadFile' 'https://onegetcdn.azureedge.net/providers/nuget-2.8.5.208.package.swidtag','C:\Users\uffemcev\AppData\Local\Temp\Micro soft.PackageManagement\g0opq1kd.ecq','40000','False' ОТЛАДКА: 00:00:02.0646664 Calling 'WebDownloader::DownloadFile' 'https://onegetcdn.azureedge.net/providers/nuget-2.8.5.208.package.swidtag','C:\Users\uffemcev\AppData\Local\Temp\Micro soft.PackageManagement\fnnmb3po.qop','40000','False' ОТЛАДКА: 00:00:02.1679162 Calling 'Bootstrap::InstallPackage' ОТЛАДКА: 00:00:02.1699852 Calling 'WebDownloader::DownloadFile' 'https://onegetcdn.azureedge.net/providers/nuget-2.8.5.208.package.swidtag','C:\Users\uffemcev\AppData\Local\Temp\Micro soft.PackageManagement\eheas4po.hin','40000','False' ОТЛАДКА: 00:00:02.2692788 Calling 'WebDownloader::DownloadFile' 'https://onegetcdn.azureedge.net/providers/Microsoft.PackageManagement.NuGetProvider-2.8.5.208.dll','C:\Users\uffemcev\ AppData\Local\Temp\Microsoft.PackageManagement\4etrokqd.h0e','-1','True' ОТЛАДКА: 00:00:02.4660174 Copying file 'C:\Users\uffemcev\AppData\Local\Temp\Microsoft.PackageManagement\4etrokqd.h0e' to 'C:\Program Files\PackageManagement\ProviderAssemblies\nuget\2.8.5.208\Microsoft.PackageManagement.NuGetProvider.dll' ОТЛАДКА: 00:00:02.4666769 Trying provider assembly: C:\Program Files\PackageManagement\ProviderAssemblies\nuget\2.8.5.208\Microsoft.PackageManagement.NuGetProvider.dll ОТЛАДКА: 00:00:02.5633138 Calling ImportPackageProvider. providerName = 'nuget', requiredVersion='2.8.5.208', minimumVersion = '', maximumVersion='' ОТЛАДКА: 00:00:02.5653466 Calling ImportPackageProviderViaName. providerName = 'nuget', requiredVersion='2.8.5.208', minimumVersion = '', maximumVersion='' ОТЛАДКА: 00:00:02.5689061 Calling ImportPackageProviderViaPath. providerName = 'C:\Program Files\PackageManagement\ProviderAssemblies\nuget\2.8.5.208\Microsoft.PackageManagement.NuGetProvider.dll', requiredVersion='2.8.5.208', minimumVersion = '', maximumVersion='' ОТЛАДКА: 00:00:02.5689991 Trying provider assembly: C:\Program Files\PackageManagement\ProviderAssemblies\nuget\2.8.5.208\Microsoft.PackageManagement.NuGetProvider.dll ОТЛАДКА: 00:00:02.5693640 Attempting loading of assembly: C:\Program Files\PackageManagement\ProviderAssemblies\nuget\2.8.5.208\Microsoft.PackageManagement.NuGetProvider.dll ОТЛАДКА: 00:00:02.5693928 Acquiring providers for assemblyC:\Program Files\PackageManagement\ProviderAssemblies\nuget\2.8.5.208\Microsoft.PackageManagement.NuGetProvider.dll ОТЛАДКА: 00:00:02.5697670 Initializing provider 'NuGet' ОТЛАДКА: 00:00:02.5710394 Calling 'NuGet'::'InitializeProvider'. ОТЛАДКА: 00:00:02.5710544 Provider 'NuGet' Initialized ОТЛАДКА: 00:00:02.5710658 Using Package Provider NuGet ОТЛАДКА: 00:00:02.5724726 Calling 'NuGet'::'GetFeatures'. ОТЛАДКА: 00:00:02.5725976 The provider 'NuGet' is imported ОТЛАДКА: 00:00:02.5775788 SUCCESS provider assembly: C:\Program Files\PackageManagement\ProviderAssemblies\nuget\2.8.5.208\Microsoft.PackageManagement.NuGetProvider.dll Installing Microsoft.WinGet.Client module... Installing winget (this takes a minute or two)... ############ # Complete # ############ winget installed successfully. Checking if winget is installed and working... winget is installed and working. You can go ahead and use it. PS C:\Users\uffemcev> ```
uffemcev commented 2 hours ago

I think problem in this command : Install-PackageProvider -Name NuGet -Force

uffemcev commented 1 hour ago

So I fixed this error. For that u can change Install-PackageProvider -Name "NuGet" -Force to:

$sourceArgs = @{
    Name = 'nuget.org'
    Location = 'https://api.nuget.org/v3/index.json'
    ProviderName = 'NuGet'
}

Register-PackageSource @sourceArgs -Force

Get-PackageProvider | where name -eq 'nuget' | Install-PackageProvider -Force

It works for powershell 5 and 7.