For C# application, it can be easily packed to a NuGet package. When I was doing internship last year, I luckily had the experience working with NuGet package using NuGet Package Explorer. After finishing a feature that can be reused in other applications, I packed it to a NuGet package. The structure of the package can be divided to couple parts, however, I only have experience dealing with lib and content.
It was quite simple to create a NuGet package with NuGet Package Explorer; template folders can be created using its GUI. By putting the
.exe to the
lib folder, the package will be able to run the program. Moreover, developers can add the folder or file to
content folder, after package installation, the files will be placed in the application with a same folder name (if it doesn't exist, it'll create one), therefore, developers can reuse these files.
For other setting such as author, package version, documentation, can all be fill out and edit on the sidebar of NuGet Package Explorer.
However, my OS is Linux mint, which means I can't use these kinds of useful tools for managing/creating NuGet package because I can neither install them, nor the functionalities are limited. In this case, I'm using .Net CLI. For every C# project, there is a
.csprj file which is automatically created while the application is created. (I was using
dotnet new console command to create my console application) The main setting for NuGet package will be done in this
<PropertyGroup> <!-- other info --> <Version>1.0.9</Version> <ToolCommandName>goodOrBad</ToolCommandName> <PackageOutputPath>./nupkg</PackageOutputPath> <Authors>Yuan-Hsi Lee, Roger Yu, Abu Zayed Kazi</Authors> </PropertyGroup>
<version> tag is your package version;
<ToolCommandName> is the command name to use this application after user install the package;
<Authors> is the place to put the Author name(s).
After testing the console application and being ready to pack to a NuGet package, move the working directory to the one contains the
.csproj file, and use
dotnet pack command. This command will create the NuGet package of this application, the package will be located in
./nupkg directory by default, you may change it in the project file.
The NuGet package can be published by updating it to NuGet Gallery. Developers can also manage the packages and view the download numbers on this website.
Before this scheduled release of the application, I actually have been packing my application into NuGet packages whenever I implemented new features. Therefore, there has been 8 versions of packages. It's a bit odd to publish these packages before a release. I eventually tag the historic commit with the respective version tag name. (i.e. tag v1.0.3 to the commit that v1.0.3 NuGet package was created) Next time, I'll make a better plan of publishing packages and make releases. Thanks to my friends who test my GoodLinkOrBadLink tool and provide user feedbacks for me to improve and fix the mistakes.