Reputation: 12226
I am using Nuget via Visual Studio's Package Manager Console. For every project I need to add few packages e.g. xunit.contribs, fluentassertions and nsubstitute. To do that I type 3 commands in consolle.
I understand that console is just another powershell host and there should be a way to create a script (kind of Add-Test-Stuff.ps1) that will add several packages at once. What is the best way to do that?
Upvotes: 4
Views: 5352
Reputation: 26257
I typically define my packages in arrays and execute them using a foreach loop
$angular = "AngularJS.Animate", "AngularJS.Core", "AngularJS.Locale", "AngularJS.Resource", "AngularJS.Route", "AngularJS.Sanitize", "AngularJS.Touch"
$angular | foreach {Install-Package $_}
This can also be written as a one-liner
"AngularJS.Animate", "AngularJS.Core", "AngularJS.Locale", "AngularJS.Resource", "AngularJS.Route", "AngularJS.Sanitize", "AngularJS.Touch" | foreach {Install-Package $_}
Upvotes: 10
Reputation: 26648
Put any script to your solution directory and you will be able to execute it from Package Manager Console.
Upvotes: 1
Reputation: 19821
It is not direct answer to you question, sorry. But I've seen very nice practive adopted for Code52 IdeaStrike project.
They do not have any packages included in source control, instead they will be installed during first build of solution and downloaded automatically, depending on packages.config
The details of configuration are here:
Using NuGet without committing packages to source control
Upvotes: 1