Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
DotNETFrameworkNotesForProfessionals.pdf
Скачиваний:
32
Добавлен:
20.05.2023
Размер:
1.82 Mб
Скачать

Chapter 28: NuGet packaging system

Section 28.1: Uninstalling a package from one project in a solution

PM> Uninstall-Package -ProjectName MyProjectB EntityFramework

Section 28.2: Installing a specific version of a package

PM> Install-Package EntityFramework -Version 6.1.2

Section 28.3: Adding a package source feed (MyGet, Klondike, ect)

nuget sources add -name feedname -source http://sourcefeedurl

Section 28.4: Installing the NuGet Package Manager

In order to be able to manage your projects' packages, you need the NuGet Package Manager. This is a Visual Studio Extension, explained in the o cial docs: Installing and Updating NuGet Client.

Starting with Visual Studio 2012, NuGet is included in every edition, and can be used from: Tools -> NuGet Package Manager -> Package Manager Console.

You do so through the Tools menu of Visual Studio, clicking Extensions and Updates:

This installs both the GUI:

Available through clicking "Manage NuGet Packages..." on a project or its References folder

And the Package Manager Console:

GoalKicker.com – .NET Framework Notes for Professionals

98

Tools -> NuGet Package Manager -> Package Manager Console.

Section 28.5: Managing Packages through the UI

When you right-click a project (or its References folder), you can click the "Manage NuGet Packages..." option. This shows the Package Manager Dialog.

Section 28.6: Managing Packages through the console

Click the menus Tools -> NuGet Package Manager -> Package Manager Console to show the console in your IDE. O cial documentation here.

Here you can issue, amongst others, install-package commands which installs the entered package into the currently selected "Default project":

Install-Package Elmah

You can also provide the project to install the package to, overriding the selected project in the "Default project" dropdown:

Install-Package Elmah -ProjectName MyFirstWebsite

Section 28.7: Updating a package

To update a package use the following command:

PM> Update-Package EntityFramework

GoalKicker.com – .NET Framework Notes for Professionals

99

where EntityFramework is the name of the package to be updated. Note that update will run for all projects, and so is di erent from Install-Package EntityFramework which would install to "Default project" only.

You can also specify a single project explicitly:

PM> Update-Package EntityFramework -ProjectName MyFirstWebsite

Section 28.8: Uninstalling a package

PM> Uninstall-Package EntityFramework

Section 28.9: Uninstall a specific version of package

PM> uninstall-Package EntityFramework -Version 6.1.2

GoalKicker.com – .NET Framework Notes for Professionals

100