If you are a NuGet package creator and want to test it before publish them, just need to register a new source in NuGet.Config
file.
OS | Path |
---|---|
Win | %appdata%\NuGet\NuGet.Config |
Mac | ~/.nuget/NuGet/NuGet.Config |
Open your file, and inside packageSources
add a new local key following this structure <add key="local" value="path" />
. This path can be a relative or absolute from NuGet.config folder.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="local" value="/Users/username/NuGet/Packages" />
</packageSources>
</configuration>
Now you can install a package locally with dotnet add package and source option to local.
dotnet add package <PACKAGE_NAME> -s local
NuGet will search the nupkg
file to be restored from your local folder.
When you want to switch to restore de Package from nuget.org
. That may show a message saying it is unable to find the new version. You'll need to clear your local packages cache before restoring.
dotnet nuget locals --clear all
Afterward, you can restore packages without a problem:
dotnet restore
or dotnet build
That’s All Folks!
Happy Coding 🖖
Top comments (0)