0

Is there a way to make the VS Package Manager commands available on Powershell Console? I looked over this link but I was unable to understand the NuGet philosophy.

I know that I can access it in Visual Studio but, let me explain my approach and goal.

I want to learn F# and for this use a lot its REPL. So basicaly, I open a Powershell console, change to my working folder, create a file with some code, fire the REPL, try various things.

In this kind of loop makes sense to have means to install various packages without starting VS and having to create a VS project.

Thanks!

Adrian
  • 1,006
  • 2
  • 9
  • 20
  • To me it seems that the reason that you don't have VS package manager Cmdlets available in PowerShell is, you need to download appropriate package from [This Link](https://dist.nuget.org/index.html) and import the required module to see those commands. – SavindraSingh Jan 22 '16 at 14:00
  • I have downloaded the nuget.exe and placed it on my path. Still I don't know how to add the cmdlets to powershell. I can run `nuget install` but not `Install-Package`. – Adrian Jan 22 '16 at 15:21
  • I have tried this on my local machine. I downloaded [This Package](https://dist.nuget.org/win-x86-commandline/latest/nuget.exe) and ran `nugget.exe install` from Windows command prompt. Latter I tried to run `Get-Command Install-Package` (under windows PowerShell). It is showing me the command as available under PackageManager module. – SavindraSingh Jan 22 '16 at 15:56

3 Answers3

0

Please refer to below screenshots:

Installing Nuget Package Manager

Verifying in PowerShell

SavindraSingh
  • 878
  • 13
  • 39
  • nuget.exe install does not install any PowerShell cmdlets. It has no PowerShell support. nuget.exe install will just try to download the NuGet packages defined in the packages.config file that it finds. The [Install-Package cmdlet](https://technet.microsoft.com/en-us/library/dn890711.aspx) is part of PowerShell 5.0 and is unrelated to the cmdlets that are available in Visual Studio. – Matt Ward Jan 23 '16 at 11:02
  • I'll try it when I will get to a windows pc. Thanks! – Adrian Jan 24 '16 at 10:02
  • I think @matt-ward is right. nuget install ries to install packages listed in packages.config in the working folder. My PowerShell version is 4.0 – Adrian Jan 25 '16 at 13:14
  • Sorry for that. I never worked on nuget. However, this is how you deal with any third party app which has PowerShell support. You need to install the application, then import the module to see respective cmdlets. – SavindraSingh Jan 27 '16 at 04:29
0

The problem is that the PowerShell cmdlets that NuGet makes available inside Visual Studio rely heavily on Visual Studio so they are not supported outside of Visual Studio from the command line.

From the command line you have NuGet.exe which supports the following which are project related:

  1. Downloading NuGet packages. Basically restoring the missing NuGet packages as defined in a packages.config file. NuGet.exe install or NuGet.exe restore
  2. Updating a NuGet package in a project. This will update the reference information but not run PowerShell scripts. NuGet update

Having the NuGet PowerShell cmdlets available on the command line is something I have looked at doing using the cmdlets that SharpDevelop provides. It is possible to fully support NuGet install/update/uninstall and have the PowerShell scripts execute on the project but in this case it requires an entire IDE, in this case SharpDevelop, to be available, at least its assemblies, even though the IDE is not run. This is needed to support updating the project file using the Visual Studio project model (EnvDTE) from within any PowerShell scripts that run.

Matt Ward
  • 47,057
  • 5
  • 93
  • 94
0

Nuget commands cannot be used outside of Visual Studio. However, if you were change to use Paket instead of Nuget, then you can use Paket from a command line outside of Visual Studio to manage your project's packages.

The getting started page is here.

Sean Kearon
  • 10,987
  • 13
  • 77
  • 93