How to create a NuGet package using cross-platform tools

Source: Internet
Author: User
Tags dotnet

Original address

Https://docs.microsoft.com/zh-cn/dotnet/articles/core/deploying/creating-nuget-packages

Content

For. NET Core 1.0, all libraries should be published as NuGet packages. In fact, this is how all. NET Standard libraries are published and used. This can be done dotnet pack easily with commands.

Let's say you've just written a great new library and want to publish it through NuGet. You can use the cross-platform tool to create a NuGet package, and do exactly as you please! The following example assumes that a library named Superawesomelibrary is used netstandard1.0 as the target.

If there are transitive dependencies, that is, if one project relies on another project, you need to make sure that you use the package that restores the entire solution before you create the NuGet package dotnet restore . Failure to do so will cause the dotnet pack command to not function properly.

After you confirm that the package has been restored, you can navigate to the directory where the library is located:

$ CD Src/superawesomelibrary

Then, just enter a command on the command line:

$ dotnet Pack

/bin/DebugThe folder now looks like this:

$ ls bin/Debugnetstandard1. 0/superawesomelibrary. 1.0. 0 . Nupkgsuperawesomelibrary. 1.0. 0. symbols.nupkg

Note that this will generate a package that can be debugged. If you want to build a NuGet package with a binary version, simply add -c / --configuration switch and use release as a parameter.

$ dotnet Pack--configuration release

/binThe folder will now contain a release folder that contains the NuGet package as a binary file version:

$ ls bin/releasenetstandard1. 0/superawesomelibrary. 1.0. 0 . Nupkgsuperawesomelibrary. 1.0. 0. symbols.nupkg

Therefore, it is now possible to publish the NuGet package with this required file!

Do not confuse dotnet pack anddotnet publish

It is important to note that not all times involve dotnet publish commands. dotnet publishcommands are used to deploy applications with all dependencies in the same package-not to build NuGet packages that are published and used by NuGet.

How to create a NuGet package with cross-platform tools (GO)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.