5
votes

How can I install nuget packages for my PowerShell Projects in Visual Studio 2015? I have tried to do it with both the PowerShell Module Project and PowerShell Script Project. I have installed PowerShell Tools for Visual Studio 2015.

When I open these projects, the Default project in the Package Manager Console is empty. Here is a screenshot of what I mean.

empty Default project:

When I try to install a nuget package, e.g. Pester, I get the following error.

PM> Install-Package Pester Install-Package : Project 'Default' is not found. At line:1 char:1 + Install-Package Pester + ~~~~~~~~~~~~~~~~~~~~~~     + CategoryInfo          : ObjectNotFound: (Default:String) [Install-Package], ItemNotFoundExc     eption     + FullyQualifiedErrorId : NuGetProjectNotFound,NuGet.PackageManagement.PowerShellCmdlets.Inst     allPackageCommand   PM>

1
Any Advance? I am ring to run tests, but I get:"Failed to load Pester module. The specified module 'Pester' was not loaded because no valid module file was found in any module directory." - XtianGIS
@XtianGIS Unfortunately I don't have any updates on this question. Your comment may be a different question altogether. - Ryan Gates
you are correct, but looking for solution to my issue, I face the same issue that you faced. either way I already raised my hand and ask the proper question. Thanks anyway - XtianGIS

1 Answers

0
votes

I know this thread might be outdated and is rather old but my older article with some possible solutions might help here. I tested current state and still, no support inside VS 2015 for PowerShell project and NuGet packages together.

the current state is :

  1. go with https://chocolatey.org/ and install it on your dev box (and CI) => you install pester globally with : choco install pester and update it if needed.
  2. use old packages.config and update by hand version number and run nuget restore (nuget update will no longer work for this type of solution).
  3. version whole pester into repo and call it directly. you can use nuget install pester for this (if you have nuget in path somewhere)

The link : http://rostacik.net/2015/12/16/how-to-use-nuget-packages-even-with-powershell-projects-with-visual-studio-2015/