Your First Package
Create and publish your first NuGet package to NugetHosting step by step.
⏱️ 5 min read
Prerequisites
Before you begin, make sure you have:
- .NET SDK 6.0 or later installed
- A NugetHosting account
- An API token created (see API Tokens)
1. Create a Class Library Project
Let's create a simple class library that we'll publish as a NuGet package:
# Create a new class library
dotnet new classlib -n MyFirstPackage
cd MyFirstPackageEdit the .csproj file to add package metadata:
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<PackageId>MyFirstPackage</PackageId>
<Version>1.0.0</Version>
<Authors>Your Name</Authors>
<Description>My first NuGet package</Description>
</PropertyGroup>2. Pack Your Package
Build and create the NuGet package:
dotnet pack -c ReleaseThis creates a .nupkg file in bin/Release/
3. Push to NugetHosting
First, add NugetHosting as a package source (if you haven't already):
dotnet nuget add source https://nuget.nugethosting.com/v3/index.json \
-n NugetHosting -u api -p YOUR_TOKENNow push your package:
dotnet nuget push bin/Release/MyFirstPackage.1.0.0.nupkg -s NugetHosting4. Verify Your Upload
Check that your package was uploaded successfully:
- Go to your NugetHosting Dashboard
- Navigate to Packages
- You should see MyFirstPackage in the list
🎉 Congratulations! You've successfully published your first package to NugetHosting!