'nuget' is not recognized but other nuget commands working

前端 未结 9 1390
走了就别回头了
走了就别回头了 2020-12-02 10:41

I am trying to create a nuget package using http://docs.nuget.org/docs/creating-packages/creating-and-publishing-a-package#From_a_convention_based_working_directory as a ref

相关标签:
9条回答
  • 2020-12-02 11:15

    In Visual Studio:

    Tools -> Nuget Package Manager -> Package Manager Console.
    

    In PM:

    Install-Package NuGet.CommandLine
    

    Close Visual Studio and open it again.

    0 讨论(0)
  • 2020-12-02 11:16

    Nuget.exe is placed at .nuget folder of your project. It can't be executed directly in Package Manager Console, but is executed by Powershell commands because these commands build custom path for themselves.

    My steps to solve are:

    • Download NuGet.exe from https://github.com/NuGet/NuGet.Client/releases (give preference for the latest release);
    • Place NuGet.exe in C:\Program Files\NuGet\Visual Studio 2012 (or your VS version);
    • Add C:\Program Files\NuGet\Visual Studio 2012 (or your VS version) in PATH environment variable (see http://www.itechtalk.com/thread3595.html as a How-to) (instructions here).
    • Close and open Visual Studio.

    Update

    NuGet can be easily installed in your project using the following command:

    Install-Package NuGet.CommandLine

    0 讨论(0)
  • 2020-12-02 11:16

    I got around this by finding the nuget.exe and moving to an easy to type path (c:\nuget\nuget) and then calling the nuget with this path. This seems to solve the problem. c:\nuget\nuget at the package manager console works as expected. I tried to find the path that the console was using and changing the environment path but was never able to get it to work in that way.

    0 讨论(0)
  • 2020-12-02 11:17

    The nuget commandline tool does not come with the vsix file, it's a separate download

    https://github.com/nuget/home

    0 讨论(0)
  • 2020-12-02 11:19

    Retrieve nuget.exe from https://www.nuget.org/downloads. Copy it to a local folder and add that folder to the PATH environment variable.

    This is will make nuget available globally, from any project.

    0 讨论(0)
  • 2020-12-02 11:28

    There are much nicer ways to do it.

    1. Install Nuget.Build package in you project that you want to pack. May need to close and re-open solution after install.
    2. Install nuget via chocolatey - much nicer. Install chocolatey: https://chocolatey.org/, then run

      cinst Nuget.CommandLine

    in your command prompt. This will install nuget and setup environment paths, so nuget is always available.

    0 讨论(0)
提交回复
热议问题