Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Create NuGet Packages From .Net Core RC2 Class Libraries

I have a solution in Visual Studio with 12 projects. I would like to create a nuget package from Visual Studio, but it appears the "Produce outputs on build" that was there from RC1 is missing.

I can go ahead and create a script that goes to each folder and call "dotnet pack", but is there an option in Visual Studio that I am missing to do this?

like image 659
David Greenwell Avatar asked May 26 '16 15:05

David Greenwell


People also ask

How do I create a .NET core NuGet package in Visual Studio 2019?

You can configure Visual Studio to automatically generate the NuGet package when you build the project. In Solution Explorer, right-click the project and choose Properties. In the Package tab, select Generate NuGet package on build.


1 Answers

Add this to your project.json file:

"scripts": {
  "postcompile": [
    "dotnet pack --no-build --configuration %compile:Configuration%"
  ]
}

This will run the dotnet pack command which will pack your build output produced after compilation into a NuGet package. For more info, see this.

I'm not sure how to only do this in release mode, so I've asked that question here.

UPDATE

Updated the answer based on the other question.

like image 119
Muhammad Rehan Saeed Avatar answered Oct 18 '22 13:10

Muhammad Rehan Saeed