1

When I'm in Visual Studio's command prompt, I can for example use nuget.exe by simply calling:

nuget -SomeParameter blabla

However, when I call this code in the Windows Powershell or command prompt outside of Visual Studio, I get:

The term nuget is not recognized as the name of a cmdlet, function, script file, or operable program. ..... //etc

How can I add a keyword to the command prompt so that the Windows powershell/command prompt recognizes it the way Visual Studio's command prompt does?

  • Try the following cmd-let in powershell: Import-VisualStudioVar, set the appriopriate version. Try to run nuget again. – Smeerpijp Feb 19 '16 at 9:29
  • Import-VisualStudioVar is not recognized by the powershell. :( – yesman Feb 19 '16 at 9:35
  • What windows and VS are you using? – Smeerpijp Feb 19 '16 at 9:36
  • Windows 7, VS2015 Enterprise. – yesman Feb 19 '16 at 9:38
  • take a look over here – Smeerpijp Feb 19 '16 at 9:40
0

I’ll preface this by saying I have not had a need for this, but, you should be able to step up a profile to handle assigning an alias for the Nuget command in your Powershell Profile. You can customize your Powershell profile to set up your environment to the way you like it, including adding an alias for any command. After you’ve made/updated your profile and saved it, it will be in effect the next time you open Powershell.

0

The Visual Studio command prompt has some initial setup scripts that add to your PATH variable. These will not get picked up in Powershell or Command Prompt unless you customize your PATH variable yourself.

The PATH variable basically tells Windows where to go to look for files or programs when you type them into the prompt without specifying their location. It will walk through the list of directories until it finds the first one that contains a file or program by that name, and then execute it.

The easiest way to customize it so that any Command Prompt or Powershell session that you open has the paths that you want is to edit your System Environment Variables through the System Properties dialog.

Right-click on My Computer and select Properties to open the System Properties control panel. In the left pane, click on Advanced System Properties. It will open the System Properties dialog window to the Advanced tab with an "Environment Variables" button on the bottom. Click that and you'll get a window like this one that lets you customize your environment variables. Environment Variables dialog window

Scroll down the "System variables" list and select the one for Path. Click the Edit button, and under "Variable value", move the cursor to the end of the line, type a semi-colon (;) and enter the full path to where your program exists (for instance, where you can find nuget.exe in your Visual Studio installation).

Click OK on all the dialog windows. Now, whenever you open a new Command Prompt or Powershell window, you can just type the name of the program and it will run. (Note that any existing Command Prompt windows you may have open while editing the PATH variable this way will not have these changes. You need to open a new window to pick them up.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.