14

I have installed the NuGet.Tools.2013.vsix on my VS2013. And I like create a nuget package from Manager Console, but when I try I get a mensagem:

The term 'nuget' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

I don't know what I do wrong.

Is possible use the Manager Console to create a package, or I need use other stuff.

AFetter
  • 3,355
  • 6
  • 38
  • 62

5 Answers5

8

Not sure I fully understand the question, but if you are using the Package Manager Console in Visual Studio then you don't need to start commands with nuget in that window. I typically use the Package Manager Console for installing/updating packages for my current solution. For example:

Install-Package Nunit

Usually you create your packages by calling nuget from the normal Windows command line with something like:

nuget pack Library.csproj

See http://docs.nuget.org/docs/creating-packages/creating-and-publishing-a-package for more info.

  • Tried that link, but pack Library.nuspec doesn't work. How can we create nuget packages without installing another program and changing the path variable? – MrFox Dec 08 '15 at 08:08
  • 1
    The question is how to nuget pack from NPC. The answer can't be "Don't use NPC, use Windows CLI" – Suamere Mar 25 '17 at 18:13
6

The NuGet Package Manager Console does not expose any commands to create NuGet packages from within Visual Studio. Neither can you use the nuget.exe commands, as you're not talking to the NuGet Command Line within the PowerShell-enabled console (unless you trick the NuGet PowerShell profile to be aware of the nuget.exe sitting on disk somewhere, by creating an alias for instance).

I did however create a NuGet package for you to install if you want to create the NuSpec files within Visual Studio (including IntelliSense). More info on my blog: http://www.xavierdecoster.com/install-nuspec-with-intellisense

This allows you to more easily author NuGet manifest files, however this still doesn't create the actual package. For that you'll have to fallback onto the nuget.exe command line tool which you can download from https://nuget.org/nuget.exe. Documentation can be found on the NuGet Docs site.

Xavier Decoster
  • 14,580
  • 5
  • 35
  • 46
2

There is a Nuget package explorer out now that will allow you to create Nuget packages using a nice little GUI. Installs via a ClickOnce deployment.

https://npe.codeplex.com/downloads/get/clickOnce/NuGetPackageExplorer.application

Matthew M.
  • 932
  • 10
  • 17
0

This is old, but I was looking for this information. I combined the information at http://docs.nuget.org/create/creating-and-publishing-a-package with information I gleaned from playing with the Package Manager Console.

I created the spec and package from the Package Manager Console by doing the following:

cd <projectFolder>
../.nuget/nuget spec

Replace <projectFolder> with the path to the project file.

That will create a spec in the project folder. (.nuspec file)

Then edit this newly created file as needed. Some information seems to be pulled in the from the AssemblyInfo file, so you may need to edit that as well.

Then

../.nuget/nuget pack <projectFileName.csproj>

Replace <projectFileName.csproj> with your project file name. (I guess it would be .vbproj for a vb project.)

seanv
  • 65
  • 6
0

Make sure that you have nuget.exe somewhere on %PATH%.

Note: We use Jenkins and needed EnvInject to get the %PATH% variable available during the build process.

Edit your .csproj file to include a new macro variable for the assembly version number, see Determine Assembly Version during a Post Build Event?

<Target Name="PostBuildMacros">
  <GetAssemblyIdentity AssemblyFiles="$(TargetPath)">
    <Output TaskParameter="Assemblies" ItemName="Targets" />
  </GetAssemblyIdentity>
  <ItemGroup>
    <VersionNumber Include="@(Targets->'%(Version)')"/>
  </ItemGroup>
</Target>
<PropertyGroup>
  <PostBuildEventDependsOn>
    $(PostBuildEventDependsOn);
    PostBuildMacros;
  </PostBuildEventDependsOn>    
  <PostBuildEvent>echo HELLO, THE ASSEMBLY VERSION IS: @(VersionNumber)</PostBuildEvent>
</PropertyGroup>

Use the following post-build script to deploy new packages whenever the assembly version has changed and a new .nupkg is required;

IF "$(ConfigurationName)" == "Release" (
  CD /D $(ProjectDir)
  IF EXIST $(TargetName).@(VersionNumber).nupkg EXIT
  nuget pack $(ProjectPath) -Properties Configuration=$(ConfigurationName)
  nuget push $(TargetName).@(VersionNumber).nupkg -s http://mynugetserver
)
Community
  • 1
  • 1
Dave Anderson
  • 11,836
  • 3
  • 58
  • 79