Consume NuGet packages in Visual Studio
source link: https://docs.microsoft.com/en-us/azure/devops/artifacts/nuget/consume?view=azure-devops
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Consume NuGet packages in Visual Studio
- 11/14/2019
- 2 minutes to read
In this article
Azure DevOps Services | TFS 2018 | TFS 2017
To consume NuGet packages from a feed, add the feed's NuGet endpoint as a package source in Visual Studio.
Azure Artifacts feeds work seamlessly with the NuGet Package Manager for Visual Studio 2015 extension as of Visual Studio 2015 Update 1. If you haven't installed Update 1 or later, you can update to the latest version of the NuGet Package Manager extension directly. Using Visual Studio for Mac? See this guidance.
Get your feed's NuGet package source information
Go to your feed (or create a feed if you haven't).
Select Connect to feed:
Select the Visual Studio tab under the NuGet header
Follow the instructions under Machine setup
Windows: Add the feed to your NuGet configuration
- On the Tools menu, select Options.
- Expand NuGet Package Manager and select Package Sources.
- Select the green plus in the upper-right corner.
- At the bottom of the dialog box, enter the feed's name and the URL that you got in the last step.
- Select Update.
- If you enabled the nuget.org upstream source, clear the check box for the nuget.org package source.
- Select OK.
- Go to the steps for consuming packages.
macOS: Add the feed to your NuGet configuration
Get a personal access token (PAT) and make a note of it.
Open the Preferences dialog box from the Visual Studio menu on the menu bar.
Select NuGet > Sources.
Select Add. Then enter your feed's name, the URL, any username, and your PAT as the password.
Select OK.
If you enabled the nuget.org upstream source, clear the check box for the nuget.org package source.
Select OK again.
Consume packages
You can now discover and use packages in this feed. To add a package reference to a project:
- Find your project in Solution Explorer.
- Right-click References.
- Select Manage NuGet Packages.
- In the Package source drop-down list, select your feed.
- Look for your package in the list.
If you're using upstream sources, package versions in the upstream source that haven't yet been saved into your feed (by using them at least once) won't appear in the NuGet Package Manager search. To install these packages:
- On the upstream source (for example, nuget.org), copy the
Install-Package
command. - In Visual Studio, open the Package Manager Console from Tools > NuGet Package Manager.
- Paste the
Install-Package
command into the Package Manager Console and run it.
Use symbols to debug
Symbol servers enable debuggers to automatically retrieve the correct symbol files for packages without knowing product names, build numbers, or package names. If symbols have been published for your packages, connect Visual Studio to the symbol server in Azure Artifacts to use symbols as you debug your packages.
Using Visual Studio 2013 or earlier
You'll need to get a personal access token. When you're prompted for a username and password, use any username and your PAT as the password.
Is this page helpful?
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK