<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Ahmed Adel</title>
    <description>The latest articles on Forem by Ahmed Adel (@ahmedsallam544).</description>
    <link>https://forem.com/ahmedsallam544</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F715294%2Ff532fc6c-16f0-467a-987c-94f5ce63d6dd.jpeg</url>
      <title>Forem: Ahmed Adel</title>
      <link>https://forem.com/ahmedsallam544</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/ahmedsallam544"/>
    <language>en</language>
    <item>
      <title>Simple Way To CreateYour NuGet Package: Step-by-Step Guide</title>
      <dc:creator>Ahmed Adel</dc:creator>
      <pubDate>Sun, 12 May 2024 21:12:47 +0000</pubDate>
      <link>https://forem.com/ahmedsallam544/simple-way-to-createyour-nuget-package-step-by-step-guide-3da1</link>
      <guid>https://forem.com/ahmedsallam544/simple-way-to-createyour-nuget-package-step-by-step-guide-3da1</guid>
      <description>&lt;p&gt;In this article, I will guide you through the process of crafting a NuGet package, from concept to publishing&lt;/p&gt;

&lt;p&gt;NuGet packages are essential building blocks for .NET development, providing reusable code and libraries.&lt;br&gt;
Creating your own package allows you to share functionality and streamline development for yourself and others.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Define Your Package’s Purpose:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The first step is to identify a clear purpose for your package.&lt;/p&gt;

&lt;p&gt;What functionality or utility will it offer?&lt;/p&gt;

&lt;p&gt;Consider common tasks or problems developers might face and how your package can address them. So our package will be a versatile .NET library designed to simplify pagination tasks within your applications. &lt;/p&gt;

&lt;p&gt;This package offers robust support for implementing pagination, filtering, and ordering functionalities in your API endpoints or data retrieval operations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Features:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Pagination Support: Easily paginate large datasets by specifying page size and retrieving paginated results, simplifying the management of data across multiple pages.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Filtering Capabilities&lt;/strong&gt;: Seamlessly filter datasets based on custom criteria, enabling users to retrieve only the data that meets specific requirements.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ordering Functionality&lt;/strong&gt;: Sort results according to specified fields and order preferences, providing flexibility in how data is presented to users.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Customizable Configuration&lt;/strong&gt;: pagination settings, filtering options, and ordering preferences to suit the unique requirements of your application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Project Structure and Code Organization:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;· Choose a project type suitable for your package’s content Class libraries (.csproj) are common for reusable code.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fofartuiqrmpx9g2i7xcu.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fofartuiqrmpx9g2i7xcu.PNG" alt="Package Class library" width="800" height="529"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;· Organize your code efficiently.&lt;/p&gt;

&lt;p&gt;· Use folders to categorize functionalities and maintain a clean separation of concerns.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fduigfp4xl87qypjbatzu.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fduigfp4xl87qypjbatzu.PNG" alt="Organize your code efficiently" width="800" height="345"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;4. Package Configuration (Project Properties):&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Most IDEs, like Visual Studio, allow to configure NuGet package properties directly within your project through Build tap and (.csproj) file configuration:&lt;/p&gt;

&lt;p&gt;· &lt;strong&gt;Package ID&lt;/strong&gt;: A unique identifier for your package on nuget.org. Choose a descriptive and memorable name.&lt;/p&gt;

&lt;p&gt;· &lt;strong&gt;Version&lt;/strong&gt;: Start with a version number like “1.0.0” and increment it for updates.&lt;/p&gt;

&lt;p&gt;· &lt;strong&gt;Authors&lt;/strong&gt;: List yourself or your team as the package creators.&lt;/p&gt;

&lt;p&gt;· &lt;strong&gt;Description&lt;/strong&gt;: Provide a clear and concise description of the package’s functionality and benefits.&lt;/p&gt;

&lt;p&gt;· &lt;strong&gt;Dependencies&lt;/strong&gt;: Specify any other NuGet packages your package relies on.&lt;/p&gt;

&lt;p&gt;· &lt;strong&gt;PackageIconUrl&lt;/strong&gt;: Provide a URL for an icon that represents your package.&lt;/p&gt;

&lt;p&gt;· &lt;strong&gt;PackageLicenseExpression&lt;/strong&gt;: Specify the license under which your package is distributed (e.g., MIT, Apache).&lt;/p&gt;

&lt;p&gt;· &lt;strong&gt;PackageTags&lt;/strong&gt;: Add relevant keywords to help users discover your package during searches.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;a) Using Build tab&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi795fz0h12oprftxzvbe.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi795fz0h12oprftxzvbe.PNG" alt="Build tab Configuration" width="800" height="449"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;b) using (.csproj) file configuration&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8ssqpsl939crx1zih8gf.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8ssqpsl939crx1zih8gf.PNG" alt="file configuration" width="770" height="462"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Build and Package (Using the CLI or IDE):&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;· Command-Line Interface (CLI): Use the Nuget pack command in your terminal or command prompt, specifying the project file path and output directory.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0zvnm4nac9v9qs9z7kqx.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0zvnm4nac9v9qs9z7kqx.PNG" alt="Nuget pack command" width="800" height="85"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;· Integrated Development Environment (IDE): Right-click on your project in the IDE and choose “Pack” under the NuGet menu or you Can just build the project finally can find The file .nupkg&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frgylv0ngbqt1vxbz5yrm.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frgylv0ngbqt1vxbz5yrm.PNG" alt="BuildPackageConfiguration" width="800" height="177"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. Testing the Package (Optional):&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;· Create a new test project that references your newly created package.&lt;/p&gt;

&lt;p&gt;· Write unit tests to verify the functionality of your code within the package.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8d8rv8w5q0nns0ylet9p.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8d8rv8w5q0nns0ylet9p.PNG" alt="Testing the Package" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;7. Publishing Your Package (nuget.org Account):&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;· Create a free nuget.org account if you don’t have one already.&lt;/p&gt;

&lt;p&gt;· Go to the “API Keys” section and generate a new key with “Push” permission for package publishing.&lt;/p&gt;

&lt;p&gt;· Use the nuget push command in the CLI, specifying the package file path, your nuget.org API key, and the source URL .&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwkf16g66rorqzvsh6los.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwkf16g66rorqzvsh6los.PNG" alt="package file path" width="800" height="375"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;· At the end, you can check published package has already been uploaded and that can anyone restore and use your package.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk77u5uf2cdyq6ttocbeo.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk77u5uf2cdyq6ttocbeo.PNG" alt="published package" width="800" height="348"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Additional Tips:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;· Consider using a continuous integration (CI) pipeline to automate building, testing, and publishing your package.&lt;/p&gt;

&lt;p&gt;· Provide clear documentation for your package, explaining usage instructions and APIs.&lt;/p&gt;

&lt;p&gt;· Maintain your package by addressing bugs by following up any reports on the package and releasing updates with new features.&lt;/p&gt;

&lt;p&gt;By following these steps, you’ll be well on your way to creating and publishing your own valuable NuGet package for the .NET community!&lt;/p&gt;

</description>
      <category>nugetpackage</category>
      <category>visualstudio</category>
      <category>dotnet</category>
    </item>
  </channel>
</rss>
