# How to Test NuGet Packages Locally Before Publishing to NuGet Feed

When developing NuGet packages, testing them in real projects before official publication is crucial. Here's a comprehensive guide to setting up local testing:

## **STEP-1: Configure Local Package Source**

Add to your `.csproj` file:

```xml
<Project Sdk="Microsoft.NET.Sdk.Web">
    <PropertyGroup>
        <TargetFramework>net9.0</TargetFramework>
        <!-- Add local package source -->
        <RestoreAdditionalProjectSources>
            $(RestoreAdditionalProjectSources);
            D:\P_Bikiran\Bikiran.Validation\bin\Release\
        </RestoreAdditionalProjectSources>
    </PropertyGroup>

    <ItemGroup>
        <PackageReference Include="Bikiran.Validation" Version="1.0.7" />
    </ItemGroup>
</Project>
```

## **2\. Package Development Workflow**

1.  **Build your package**
    
    Ensure your package project is built in the Release configuration
    
    ```bash
    dotnet build -c Release
    ```
    
2.  **Generate a** `.nupkg` **file**
    
    ```bash
    dotnet pack --configuration Release
    ```
    
3.  **Verify package structure**
    
    Confirm the .nupkg file exists in your output directory:
    
    ```bash
    D:\P_Bikiran\Bikiran.Validation\bin\Release\Bikiran.Validation.1.0.7.nupkg
    ```
    

## **3\. Consumption in Live Projects**

```csharp
using Bikiran.Validation; // Your local package
using Bikiran.Utils.ApiResp;

public class DomainCnsAddProperty
{
    public string Cns { get; set; } = "";
    public List<string> Ips { get; set; } = [];

    public ApiResponse Validate()
    {
        var validationResult = ValidateBasic.ValidateAll([
            ValDomain.IsValidDomainFormat(Cns, "Child Name Server"),
            ValIP.IsValidIpFormatAll(Ips, "IP Addresses"),
        ]);

        return new ApiResponse {
            Error = validationResult.Error,
            Message = validationResult.Message,
            ReferenceName = GetReferenceName(validationResult.ErrorIndex)
        };
    }

    private string GetReferenceName(List<string> names, int? errorIndex)
        => errorIndex.HasValue ? names[errorIndex.Value] : "Validation";
}
```

## **Best Practices**

1.  **Version Management**
    
    *   Increment versions systematically (SemVer recommended)
        
    *   Use wildcards for development versions: `1.0.*`
        
2.  **Dependency Isolation**
    
    ```xml
    <PackageReference Include="Bikiran.Validation" Version="1.0.7">
      <PrivateAssets>all</PrivateAssets>
    </PackageReference>
    ```
    
3.  **CI/CD Integration**
    
    Consider adding a local package directory in your build pipeline:
    
    ```xml
    <RestoreAdditionalProjectSources>
      $(RestoreAdditionalProjectSources);
      $(Build.SourcesDirectory)\artifacts
    </RestoreAdditionalProjectSources>
    ```
    

## **Troubleshooting Common Issues**

1.  **Package Not Found**
    
    *   Verify the `.nupkg` file exists at the specified path
        
    *   Check package version consistency
        
    *   Clear NuGet caches: `dotnet nuget locals all --clear`
        
2.  **Version Conflicts**
    
    Use exact versions during development:
    
    ```xml
    <PackageReference Include="Bikiran.Validation" Version="[1.0.7]" />
    ```
    
3.  **IntelliSense Issues**
    
    *   Restart IDE after package updates
        
    *   Run `dotnet restore` manually
        

### **CONTACT:**

I’m Kumar Bishojit Paul, the Founder and CEO of [BIKIRAN](https://www.bikiran.com/). If you need further assistance, please leave a comment. I’m interested in helping you.


---

## 🏢 About Bikiran

**[Bikiran](https://bikiran.com/)** 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](https://bikiran.com/)                                      | Main platform — Domain, hosting & cloud services        |
| 2   | Website      | [Edusoft](https://www.edusoft.com.bd/)                               | Education management software for institutions          |
| 3   | Website      | [n8n Clouds](https://n8nclouds.com/)                                 | Managed n8n workflow automation hosting                 |
| 4   | Website      | [Timestamp Zone](https://www.timestamp.zone/)                        | Unix timestamp converter & timezone tool                |
| 5   | Website      | [PDFpi](https://pdfpi.bikiran.com/)                                  | Online PDF processing & manipulation tool               |
| 6   | Website      | [Blog](https://blog.bikiran.com/)                                    | Technical articles, guides & tutorials                  |
| 7   | Website      | [Support](https://support.bikiran.com/)                              | 24/7 customer support portal                            |
| 8   | Website      | [Probackup](https://probackup.bikiran.com/)                          | Automated database backup for SQL, PostgreSQL & MongoDB |
| 9   | Service      | [Domain](https://www.bikiran.com/domain)                             | Domain registration, transfer & DNS management          |
| 10  | Service      | [Hosting](https://www.bikiran.com/services/hosting/web)              | Web, app & email hosting on NVMe SSD                    |
| 11  | Service      | Email & SMS                                                          | Bulk email & SMS notification service                   |
| 12  | npm          | [Chronopick](https://www.npmjs.com/package/@bikiran/chronopick)      | Date & time picker React component                      |
| 13  | npm          | [Rich Editor](https://www.npmjs.com/package/@bikiran/editor)         | WYSIWYG rich text editor for React                      |
| 14  | npm          | [Button](https://www.npmjs.com/package/@bikiran/button)              | Reusable React button component library                 |
| 15  | npm          | [Electron Boilerplate](https://www.npmjs.com/package/create-edx-app) | CLI to scaffold Electron.js project templates           |
| 16  | NuGet        | [Bkash](https://www.nuget.org/packages/Bikiran.Payment.Bkash)        | bKash payment gateway integration for .NET              |
| 17  | NuGet        | [Bikiran Engine](https://www.nuget.org/packages/Bikiran.Engine)      | Core .NET engine library for Bikiran services           |
| 18  | Open Source  | [PDFpi](https://github.com/bikirandev/pdfpi)                         | PDF processing tool — open source                       |
| 19  | Open Source  | [Bikiran Engine](https://github.com/bikirandev/Bikiran.Engine)       | Core .NET engine — open source                          |
| 20  | Open Source  | [Drive CLI](https://github.com/bikirandev/DriveCLI)                  | CLI tool to manage Google Drive from terminal           |
| 21  | Docker       | [Pgsql](https://github.com/bikirandev/docker-pgsql)                  | Docker setup for PostgreSQL                             |
| 22  | Docker       | [n8n](https://github.com/bikirandev/docker-n8n)                      | Docker setup for n8n automation                         |
| 23  | Docker       | [Pgadmin](https://github.com/bikirandev/docker-pgadmin)              | Docker setup for pgAdmin                                |
| 24  | Social Media | [LinkedIn](https://www.linkedin.com/company/bikiran12)               | Bikiran on LinkedIn                                     |
| 25  | Social Media | [Facebook](https://www.facebook.com/bikiran12)                       | Bikiran on Facebook                                     |
| 26  | Social Media | [YouTube](https://www.youtube.com/@bikiranofficial)                  | Bikiran on YouTube                                      |
| 27  | Social Media | [FB n8nClouds](https://www.facebook.com/n8nclouds)                   | n8n Clouds on Facebook                                  |
