Using nuget packages in ASP.NET Core
While developing ASP.NET Core you might face some situations where you have the source code with you, but the nuget package is not available. One example is ImageProcessorCore where source code is available, but nuget package is not available, if you want to use this library in your project, you first need to create a package out of it and host it locally.
Creating Nuget package from ASP.NET Core Class Library - Prior to Visual Studio 2015 Update 3, in the Project properties Build Tab has an option - “Produce outputs on build”, which will generate nuget package for you. But Visual Studio team removed this option, so you need to use commandline tools to create nuget packages. First you need to execute the “dotnet restore” command, to restore all the dependencies. After that, you need to execute the “dotnet pack” command, which will compile the project and create the nuget package under bin folder.
To consume it you can either create a nuget.config file in your root directory, where you need to add ASP.NET Core related nuget repositories and you local package directory. Here is one example nuget.config.
You can also modify global nuget config using Visual Studio, which is available here “%APPDATA%\NuGet\NuGet.Config”. In Visual Studio, under Tools, select the “Nuget Package Manager” then select the “Package Sources” tab. And add your package source.
Now if you run the “dotnet restore” command, you can see the ImageProcessorCore reference in the project.json.lock file.
Happy Programming :)