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.
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.
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.
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.
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 ”,
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.
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>
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With