It’s been a while since I had to build a NuGet package, a long while. While as a developer I use multiple NuGet packages all the time in my applications, I think I’ve created only a few of my own. Needless to say, I am a total noob when it comes to building AND publishing NuGet packages.
So the other day the need to do this presented itself, and while building a Nuget package isn’t difficult at all, that said, there are times when you need to do something that isn’t as basic as the multiple examples given on StackOverflow or Microsoft Docs. This was one of those times, I needed to create a NuGet package that will contain just one public method but in order to run properly, it required references to multiple project dependencies.
As I was doing this I also run into other errors that perhaps someone with experience building NuGet packages wouldn’t ever run into as my problem was that I didn’t know about specific options that you need to include when building your NuGet package. This is a small post about those two very important command options and hopefully, when you run into a similar problem, this works as a solution for you too.
If you don’t have the nuget.exe in your computer yet, you can download the latest version from here.
- Open a command window and browse to where your project file is.
- nuget spec
- nuget pack -Prop Configuration=Release -IncludeReferencedProjects