From the course: .NET Deep Dive: NuGet Package Manager
Windows Terminal and NuGet - NuGet Tutorial
From the course: .NET Deep Dive: NuGet Package Manager
Windows Terminal and NuGet
- [Instructor] While the Visual Studio NuGet tools are convenient, there are times when it is preferable to use command line interfaces. There are two CLIs available, the dotnet CLI and the NuGet CLI. Check out the installer videos in this course to see how to get them on your computer. I'm using the windows terminal in the powershells tab, and I'm looking at the solution folder for the course. You can see it here, I'm in the source folder. You can see I've customized my prompt to show the path and some git information too, I can see I'm on branch 08-01, and I can also see the status of my repo files. Anyway, this shell is how I'll use the CLIs in this chapter. The first step is to run NuGet and see the available commands. So I can see, I can add packages to a hierarchical data source, for example, my private feed. I can delete packages from a server, I can install packages using a specified source, I can also list those packages. If I am a creator of packages, I can use pack to create the get package, and I can also use push to push that package to the server and publish it. I'll clear the screen, and then I'll run get command. What this does is show me when I run NuGet, what executable is running. So I can see I'm running this NuGet.exe and I'm running version 5.9.1.0. Now the other CLI is dotnet. So let's look at the command for that, and I can see that this is running donet.exe. Dotnet.exce is a more general purpose tool, it has many dotnet related commands, including some that work with NuGet. So I can go and call dotnet, add. So add is a general dotnet command, but by using the word package here, I'm now using some of the features that are in the NuGet executable. So what happens here is the dotnet CLI uses some library functions of NuGet to execute the grants such as add package. There's another way to get some of those commands by typing in NuGet here. So it's dotnet nuget. When I hit Enter on this, I get a list of the available commands here. So I can say I can add a NuGet source, the latest package from the server, lists a configured NuGet sources, push a package to the server and so on. This is a subset of what's available in the NuGet CLI. So these will make calls to the real NuGet exe in most cases, and there are some NuGet helper DLLs that are installed with the dotnet CLI. Let's talk about when we use both. There are commands that are only available in the NuGet CLI plus it's the one you want to use if you're working in a dotnet framework project. There are benefits for using the dotnet CLI too, for example, it can modify the contents of my csproj file while NuGet can't. We'll use both in this chapter.