First, make sure that Shape
and Factory
are public. If you don't specify their visibility, they're private by default, which means that they can not be used directly by other projects, either as package reference or project references.
When you pack master
into a NuGet package, the default file it will create is bin\Debug\master.1.0.0.nupkg
. Assuming master
is targetting .NET Standard 2.0, master's dll is saved as lib\netstandard20\master.dll
in the nupkg
. You need add/push this nupkg
to a nuget feed (can be a directory on your computer or network, nuget.org or you can host your own feed). Your comsumer
project will need a nuget.config
that adds the correct NuGet feed as a source, then you add a package reference to the master package. After you restore (which Visual Studio does automatically if you added the package with the UI), then you can use any of master's public classes.
Here's commands you can run on the command line to set up two projects, one is a package, the other will consume it. If you're using .NET Core in Visual Studio, it must have already downloaded the .NET Core SDK, which puts the dotnet cli on your path. You'll also need to download nuget.exe from https://www.nuget.org/downloads/.
dotnet new nugetconfig
nuget source -configfile nuget.config add -name local -source feed
# create an isolated nuget environment, because I don't like to populate
# my global packages folder with test packages
nuget config -configfile nuget.config -set globalPackagesFolder=gpf
# create a library, pack it, and add the nupkg to our local feed
dotnet new classlib -n MyLib
dotnet pack MyLib\MyLib.csproj -o nupkgs\
nuget add MyLib\bin\Debug\MyLib.1.0.0.nupkg -s local
# create console app and reference MyLib
dotnet new console -n MyApp
dotnet add MyApp\MyApp.csproj package MyLib --version 1.0.0
#if you want to open these projects in Visual Studio
dotnet new sln -n sample
dotnet sln add MyLib\MyLib.csproj
dotnet sln add MyApp\MyApp.csproj
start sample.sln
Normally you wouldn't use a NuGet package to use one project from another project in the same solution. Just make them project references, and when you pack a project into a NuGet package, the project reference becomes a NuGet dependency. I only did it this way to demonstrate how to easily consume a package that you created yourself.