How to generate .Net core package Nuget

    Previously referenced a lot neget package, feel nuget pack a lot of convenience, is not some generic code can be encapsulated into nuget in, when you want to use a reference to it,

In fact, this has two advantages:

    1. First, do not repeat coding, saving time.

    2. Then paste avoid replication errors caused, directly available.

So how to package nuget package yet.

First, we can create a class library, of course, the console program can also be packaged.

 

 Then we will need to encapsulate code written into this library, here to write an example.

 

 Then we can pack up, click Build Solution, of course, where you can use debug, or release, recommended release.

Then in the directory of our project, shift plus right, open a command line window. Input:

dotnet pack --no-build -c release -p:PackageVersion=1.1.0

 

 

Explain here, here --no-build is not to build, we need to build on their own in vs, repacking after a successful no errors, avoid packing error.

-c is specified built, you can debug it can also be a release.

-P later version specified package, we iterate here when you can easily manage.

Specific documentation can be seen: https://docs.microsoft.com/zh-cn/dotnet/core/tools/dotnet-pack

Of course, we can also pack on vs, but are the default settings.

Then we set a good path can be cited: Tools >> Options >> nuget Package Manager package source >>

 

 After the package will generate .nupkg suffix file, set the location of your .nupkg files can be cited.

 

 Generally is the case, if wrong, please correct me.

 

Guess you like

Origin www.cnblogs.com/Ivan-Wu/p/11646460.html