Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add custom package source to Visual Studio Code

Does anybody know how to add custom package source to Visual Studio Code?

E.g. I'd like to add https://www.myget.org/F/aspnet-contrib/api/v3/index.json as a package source and drive these packages through project.json.

like image 915
Tomino Avatar asked Dec 28 '16 08:12

Tomino


People also ask

How do I add package sources in Visual Studio?

In Visual Studio, select Tools, and then select Options. Select NuGet Package Manager, and then select Package Sources. Enter the feed's Name and Source URL, and then select the green (+) sign to add a new package source.

How do I install a package in Visual Studio?

Accept the default values for Framework when prompted. Visual Studio creates the project, which opens in Solution Explorer. To install the package, you can use either the NuGet Package Manager or the Package Manager Console.

How do I change the source of a package in Visual Studio?

To add a source, select +, edit the name, enter the URL or path in the Source control, and select Update. The source now appears in the selector drop-down. To change a package source, select it, make edits in the Name and Source boxes, and select Update.

How to manage NuGet packages in Visual Studio Code?

a. Way 1: Open Solution Explorer, Select & right click on your Project, then Choose “ Mange NuGet Packages …” from context menu, It will open NuGet Package Manger window. b. Way 2: Go to “ Tools” menu => Options … => on Left Menu Tab select “ Nuget Package Manager ” => “ Package Sources ”,

How to add custom NuGet source in VSCode?

If you can access the nuget source in Visual Studio, then you can do it in VSCode as well. You need to make sure the URL you put in value is correct. You can check if it is correct or not by using the option "Manage Nuget Packages" in Visual Studio, and adding your custom nuget source there.


2 Answers

To add to the answer, adding a nuget.config in the project solves it for the project. Adding to the root is ok. The config could look like this:

<?xml version="1.0" encoding="utf-8"?> <configuration>   <packageSources>     <add key="MyGet" value="https://www.myget.org/F/aspnet-contrib/api/v3/index.json" />   </packageSources> </configuration> 
like image 108
Alvis Avatar answered Sep 20 '22 04:09

Alvis


Another option that worked for me and was actually needed as part of my CI/CD pipeline is to use dotnet nuget add source <repo-url> --name <repo-name>

Simply call that before you call dotnet restore or dotnet build

Reference: https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-nuget-add-source

like image 41
BearsEars Avatar answered Sep 23 '22 04:09

BearsEars