2016-04-09 158 views
1

Power Shellスクリプトを使用してNUnitパッケージをダウンロードしてインストールする方法を調べようとしています。Powershell Nugetパッケージをインストール

私はInstall-Packageコマンドを試しましたが、NUGet Package Manager Consoleの場合はもちろんです。何か案は?

答えて

0

Install-Packageを使用してNUnitを検索してダウンロードするには、NuGetパッケージプロバイダが必要です。私が思っている問題は、これまでにInstall-Package NUnitのようなコマンドを実行したときにNuGetパッケージプロバイダをPowerShell用にインストールまたは設定していないと、NuGetパッケージプロバイダをインストールするかどうかを尋ねるプロンプトが表示されます。

例:私はNuGetプロバイダを設定した後

Find-Package NUnit 
WARNING: The specified PackageManagement provider 'NuGet' is not available. 
Find-Package : No match was found for the specified search criteria and package name 'NUnit'. 
At line:1 char:1 
+ Find-Package NUnit 
+ ~~~~~~~~~~~~~~~~~~ 
+ CategoryInfo   : ObjectNotFound: (Microsoft.Power...ets.FindPackage:FindPackage) [Find-Package], Exception 
+ FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.FindPackage 

はしかし、それだけで正常に動作します:

Find-Package -Name Nunit 

Name       Version   Source       Summary                            
----       -------   ------       -------                            
NUnit       3.2.0   nuget.org      NUnit is a unit-testing framework for all .Net languages with a strong TDD focus. 
0

私の答えは、@ Negorathの時に構築しています。あなたは私がNuGetを持って見ることができるように

> Get-PackageProvider -ListAvailable 

Name      Version   DynamicOptions 
----      -------   -------------- 
msi      3.0.0.0   AdditionalArguments 
msu      3.0.0.0 
NuGet     2.8.5.208  Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag, Contains, AllowPrereleaseVersions, ConfigFile, SkipValidate 
PowerShellGet   1.0.0.1   PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, InstallUpdate, NoPathUpdate, Filter, Tag, Includes, DscResource, RoleCapability, Command, PublishLocation, ScriptSourceL... Programs     3.0.0.0   IncludeWindowsInstaller, IncludeSystemComponent 

:私は、彼らはいくつかの詳細が欠けていると信じています。しかし、あなたがインストールできない場合は:

> Register-PackageSource -Name NuGet -ProviderName PowerShellGet -Verbose 
VERBOSE: Repository details, Name = 'PSGallery', Location = 'https://www.powershellgallery.com/api/v2/'; IsTrusted = 'False'; IsRegistered = 'True'. 
VERBOSE: Performing the operation "Register Package Source." on target "Package Source 'NuGet'() in provider 'PowerShellGet'.". 
関連する問題