NuGet--Using the console to manage packages

Source: Internet
Author: User

Why would you want to use the console management package instead of the Package management window? The reason everybody understands, life pressure is so big, everything is just to pack a wave. A joke, of course, not only for this reason, in some cases, some operations using the Package Management window can not achieve the purpose, can only be implemented using console commands, for example, install a specific version of the package.
Console Command WindowThe process to open the NuGet command window on vs with the NuGet plugin installed is as follows: Select Menu Tools (Tools)->library Package Manager (Library packages manager)->pakcage Manager Console (Package Manager console).
    • Package Source: This drop-down box lets you select the source of the NuGet official package that you want to use with the package source, and of course you can switch to the package source used internally by your company.
    • Default project: Choose which project you want to work with, and the first item is automatically selected by default.

In the process of using console commands, the syntax of many commands does not require a hard back, and you can use the Get-help command to view help at any time.
Common Commands
    • Get-package
you can use Get-package-listavailable to view all available packages for the current package source. Using the above command to get thousands of packages from the source of the NuGet official package, if you want to query a specific package, you can use the-filter parameter to filter, if I need to find the Common.loggin package, then you can use the Get-package- Listavailable-filter common.logging (package name or keyword) to find, in the NuGet 3.0+ version, you can use the Find-package command to replace the Get-package command. If you do not have any parameters, you can view the list of installed packages for the current solution:
    • Install-package
After you use the Get-package command to locate the package that you want to install, you can use the Install-package packagename command to install the package. For example, use Install-pakcage common.logging to install a common Log package: NuGet will look up from the specified package source when it installs the package, and will be installed into the selected project (unless you specify it with a parameter). The package file is downloaded to the local solution's packages directory, and the project's app. config or Web. config may also be changed. If the package you are installing depends on other packages, NuGet downloads and installs the packages on which it depends.
    • Uninstall-package
Use Uninstall-package PackageName to remove the specified package from the currently selected item. For example, Uninstall-pakcage common.logging removes the common.logging package that is referenced by the current project. Results achieved using the above command:
    1. Project reference: In Solution Explorer, the common.logging reference in the project reference is deleted
    1. Packages Directory: The solution folder root directory under the Packages Directory Common.logging folder is deleted, if there is only one directory under packages, then the packages directory will also be deleted;
    2. Configuration file: Changes in app. config or Web. config files are deleted;

    • Update-package
You can use the Get-package-updates command to see if a new version is available in the currently installed package: If you want to update a package, you can use Update-package packagename to update the specified package.
Summary This article explains how to use the package console for simple package management, including common find, install, delete, and update package features. The General command is so much, of course, the application of each command is just its basic usage, if you need a deeper application, you can use the Get-help commandname to see the detailed use of each command, you can also directly view the official documentation.
References:1. Official website console command document: Http://docs.nuget.org/consume/Package-Manager-Console

NuGet--Using the console to manage packages

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.