如何在Windows 10的PowerShell中安装NuGet?

时间:2019-04-12 07:00:53

标签: windows powershell

我在Linux上工作多年后最近购买了Windows 10,并且想要安装 PSReadLine 完成模块,因为我首先需要获得VS随附的 NuGet Studio2017。我安装了VS Studio 2017,然后以管理员身份打开PowerShell,并尝试通过Install-Module -Name PSReadLine安装该模块,但得到:

WARNING: Unable to download from URI 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409' to ''.
WARNING: Unable to download the list of available providers. Check your internet connection.
PackageManagement\Install-PackageProvider : 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.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:7468 char:21
+ ...     $null = PackageManagement\Install-PackageProvider -Name $script:N ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (Microsoft.Power...PackageProvider:InstallPackageProvider) [Install-Pac
   kageProvider], Exception
    + FullyQualifiedErrorId : NoMatchFoundForProvider,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackagePro
   vider

我尝试使用google进行搜索,但到目前为止,没有“解决方案”有助于安装它。有人可以帮我设置这个吗?

1 个答案:

答案 0 :(得分:3)

启用TLS 2

[Net.ServicePointManager] :: SecurityProtocol = [Net.SecurityProtocolType] :: Tls12

再试一次

Install-Module MSOnline