Skip to main content

Command Palette

Search for a command to run...

Creating and Publishing .NET NuGet Packages

Updated
5 min read
Creating and Publishing .NET NuGet Packages

SETP-1: Prerequisites

Verify installation: After a successful installation, you could verify by the cmd/bash.

dotnet --version

SETP-2: Create a class library project

Using this command, a project named MyAwesomePackage will be created.

dotnet new classlib -n MyAwesomePackage
cd MyAwesomePackage

SETP-3: Open an Editor and Add your code

XML comments are necessary for proper documentation.

namespace MyAwesomePackage;

/// <summary>
/// Provides basic arithmetic operations
/// </summary>
public class Calculator
{
    /// <summary>
    /// Adds two integers
    /// </summary>
    /// <param name="a">First number</param>
    /// <param name="b">Second number</param>
    /// <returns>Sum of a and b</returns>
    public int Add(int a, int b) => a + b;
    
    // Add similar documentation for Multiply
}

SETP-4: Configure Package Metadata

Here is a basic project setup file, MyAwesomePackage.csproj

<Project Sdk="Microsoft.NET.Sdk">
	<PropertyGroup>
		<TargetFramework>net9.0</TargetFramework>
		
		<!-- Core Package Metadata -->
		<PackageId>MyAwesomePackage</PackageId>
		<Version>1.0.1</Version>
		<Authors>bishojit</Authors>
		<Company>BIKIRAN</Company>
		<Description>Utility functions for common operations</Description>
		<PackageTags>utilities helper tools</PackageTags>

		<!-- Recommended Additions -->
		<PackageProjectUrl>https://github.com/bikirandev/bikiran.utils</PackageProjectUrl>
		<RepositoryUrl>https://github.com/bikirandev/bikiran.utils.git</RepositoryUrl>
		<PackageLicenseExpression>MIT</PackageLicenseExpression>
		<IncludeSymbols>true</IncludeSymbols>
		<SymbolPackageFormat>snupkg</SymbolPackageFormat>
		
		<!-- Add below existing PackageTags -->
		<PackageReadmeFile>README.md</PackageReadmeFile>
	</PropertyGroup>

	<ItemGroup>
		<!-- Add NuGet.Protocol package reference -->
		<PackageReference Include="NuGet.Protocol" Version="6.13.2" />
	</ItemGroup>

	<ItemGroup>
		<None Include="README.md" Pack="true" PackagePath="\" />
	</ItemGroup>
</Project>

STEP-5: Build the Package

After developing all the operations, you need to build the package before publishing it.

dotnet build

STEP-6: Create NuGet Package

Make sure to fix all errors and warnings before publishing.

dotnet pack --configuration Release

STEP-7: Requirements before publishing

  1. Add a LICENSE File (Required)

  2. Add README.md (Required)

  3. I repeat, must add XML comment documentation on each class.

  4. Add Package Icon (Optional)

STEP-8: Publish to NuGet.org

  • Log in > Click Upload (On Top Navigation Bar)

  • Locate your file and upload it.

  • After a successful upload, complete the form.

  • After a few minutes, the Package will be approved.

Important Notes:

  1. Versioning: Increment <Version> before each new release

  2. The package ID must be unique across NuGet.org

  3. Recommended: Use Semantic Versioning

  4. For private feeds: Change --source to your feed URL

Next Steps:

  1. Add documentation in README.md

  2. Consider adding:

    • XML documentation comments

    • License file

    • Icon

    • Release notes

CONTACT:

I’m Kumar Bishojit Paul, the Founder and CEO of BIKIRAN. If you need further assistance, please leave a comment. I’m interested in helping you.


🏢 About Bikiran

Bikiran is a software development and cloud infrastructure company founded in 2012, headquartered in Khulna, Bangladesh. With 15,000+ clients and over a decade of experience, Bikiran builds and operates a suite of products spanning domain services, cloud hosting, app deployment, workflow automation, and developer tools.

SL Topic Product Description
1 Website Bikiran Main platform — Domain, hosting & cloud services
2 Website Edusoft Education management software for institutions
3 Website n8n Clouds Managed n8n workflow automation hosting
4 Website Timestamp Zone Unix timestamp converter & timezone tool
5 Website PDFpi Online PDF processing & manipulation tool
6 Website Blog Technical articles, guides & tutorials
7 Website Support 24/7 customer support portal
8 Website Probackup Automated database backup for SQL, PostgreSQL & MongoDB
9 Service Domain Domain registration, transfer & DNS management
10 Service Hosting Web, app & email hosting on NVMe SSD
11 Service Email & SMS Bulk email & SMS notification service
12 npm Chronopick Date & time picker React component
13 npm Rich Editor WYSIWYG rich text editor for React
14 npm Button Reusable React button component library
15 npm Electron Boilerplate CLI to scaffold Electron.js project templates
16 NuGet Bkash bKash payment gateway integration for .NET
17 NuGet Bikiran Engine Core .NET engine library for Bikiran services
18 Open Source PDFpi PDF processing tool — open source
19 Open Source Bikiran Engine Core .NET engine — open source
20 Open Source Drive CLI CLI tool to manage Google Drive from terminal
21 Docker Pgsql Docker setup for PostgreSQL
22 Docker n8n Docker setup for n8n automation
23 Docker Pgadmin Docker setup for pgAdmin
24 Social Media LinkedIn Bikiran on LinkedIn
25 Social Media Facebook Bikiran on Facebook
26 Social Media YouTube Bikiran on YouTube
27 Social Media FB n8nClouds n8n Clouds on Facebook