I am working on a project that has a dependency on a NuGet project that is on an external source. We are using package restore and not committing packages into Git. For developers that do not have this source configured in their NuGet settings, is there a way to specify in the packages.config file that this package should be pulled from a different source?
e.g.,
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Antlr" version="3.4.1.9004" targetFramework="net45" />
<package id="bootstrap" version="3.0.0" targetFramework="net45" />
...
<!-- How do I specify that this custom package comes from a different source? -->
<package id="MyCustomPackage" version="1.0.0" targetFramework="net45" />
...
<package id="Respond" version="1.2.0" targetFramework="net45" />
<package id="WebGrease" version="1.5.2" targetFramework="net45" />
</packages>
To manage your package sources, select the Settings icon or select Tools > Options. In the Options window, expand the NuGet Package Manager node and select Package Sources. To add a source, select +, edit the Name, enter the URL or path in Source, and then select Update.
After you install a NuGet package, you can then make a reference to it in your code with the using <namespace> statement, where <namespace> is the name of package you're using.
Open the Package Manager UI - Right-click on References and select Manage NuGet Packages... Open the Package Manager Console - From Tools > NuGet Package Manager , select Package Manager Console. Run NuGet restore - Right-click on the solution node in the Solution Explorer and select Restore NuGet Packages.
Install packages from NuGet.orgSelect Package Manager, and then copy the Install-Package command. In Visual Studio, select Tools > NuGet Package Manager > Package Manager Console to open the package manager console. Paste the command into the Package Manager Console and then press Enter.
Each user can have their own config file, where you can specify the location of the sources:
<packageSources>
<add key="NuGet official package source" value="https://nuget.org/api/v2/" />
<add key="TestSource" value="C:\Temp" />
</packageSources>
For more info, see docs here
You can also configure this at the project or solution level by adding a NuGet.config to the project or solution.
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