[英]How do I install MongoDB driver for PowerShell using Install-Package?
I am trying to interact with MongoDB from powershell and need to install the driver package.我正在尝试从 powershell 与 MongoDB 交互,并且需要安装驱动程序包。 Per instructions from https://www.nuget.org/packages/mongodb.driver I issue the command:
根据https://www.nuget.org/packages/mongodb.driver 的说明,我发出命令:
Install-Package MongoDB.Driver -Version 2.8.0
But I get an error:但我收到一个错误:
Install-Package : A parameter cannot be found that matches parameter name 'Version'.
At line:1 char:32
+ Install-Package MongoDB.Driver -Version 2.8.0
+ ~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Install-Package], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage
Not sure how to proceed.不知道如何继续。
> Get-PackageSource
Name ProviderName IsTrusted Location
---- ------------ --------- --------
PSGallery PowerShellGet False https://www.powershellgallery.com/api/v2
nuget.org NuGet False https://api.nuget.org/v3/index.json
My Downloads NuGet False C:\Users\Richard\Downloads
I tried downloading and installing from there, but still get an error:我尝试从那里下载和安装,但仍然出现错误:
> Install-Package -scope currentuser mongodb.driver
The package(s) come(s) from a package source that is not marked as trusted.
Are you sure you want to install software from 'My Downloads'?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): y
Install-Package : One or more errors occurred.
At line:1 char:1
+ Install-Package -scope currentuser mongodb.driver
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: ($TXkgRG93bmxvYW...2ZXI=\Mi44LjA=\:String) [Install-Package], Exception
+ FullyQualifiedErrorId : One or more errors occurred.,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage
you can use .NET CLI and use this command您可以使用 .NET CLI 并使用此命令
dotnet add package MongoDB.Driver --version 2.8.0
dotnet 添加包 MongoDB.Driver --version 2.8.0
or或者
dotnet add package MongoDB.Driver --version 2.9.0-beta1
dotnet 添加包 MongoDB.Driver --version 2.9.0-beta1
or remove version to install last stable version automaticly like:或删除版本以自动安装最新的稳定版本,例如:
Install-Package MongoDB.Driver
安装包 MongoDB.Driver
also see this articel :另见这篇文章:
https://docs.microsoft.com/en-us/nuget/consume-packages/package-restore-troubleshooting https://docs.microsoft.com/en-us/nuget/consume-packages/package-restore-troubleshooting
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.