This guide explains how to build, pack, and publish this NuGet package.
- .NET 8 SDK or later
- Git
- A NuGet.org account (for publishing)
git clone https://github.com/openmindednewby/MultiTenancy.EntityFrameworkCore.git
cd MultiTenancy.EntityFrameworkCoredotnet restore# Debug build
dotnet build
# Release build
dotnet build -c Releasedotnet testdotnet pack -c Release -o ./artifactsThis creates a .nupkg file in the ./artifacts folder.
dotnet pack -c Release -o ./artifacts /p:Version=1.0.1Before publishing to NuGet.org, test the package locally:
# Create a local NuGet directory
mkdir C:\LocalNuGet
# Pack to local directory
dotnet pack -c Release -o C:\LocalNuGet
# Add local source (one-time setup)
dotnet nuget add source C:\LocalNuGet -n LocalFeed
# In your test project
dotnet add package MultiTenancy.EntityFrameworkCore --version 1.0.0 --source LocalFeedIn your test project's .csproj:
<ItemGroup>
<PackageReference Include="MultiTenancy.EntityFrameworkCore" Version="1.0.0">
<Source>C:\path\to\MultiTenancy.EntityFrameworkCore\artifacts\MultiTenancy.EntityFrameworkCore.1.0.0.nupkg</Source>
</PackageReference>
</ItemGroup>- Go to https://www.nuget.org/account/apikeys
- Click Create
- Provide a key name (e.g., "MultiTenancy.EntityFrameworkCore")
- Select Push scope
- Select packages or glob pattern (e.g.,
MultiTenancy.EntityFrameworkCore*) - Copy the generated API key
dotnet nuget push ./artifacts/MultiTenancy.EntityFrameworkCore.1.0.0.nupkg \
--api-key YOUR_API_KEY \
--source https://api.nuget.org/v3/index.jsonSecurity Note: Never commit your API key to source control!
NuGet.org takes 5-15 minutes to index new packages. You can monitor the status at: https://www.nuget.org/packages/MultiTenancy.EntityFrameworkCore
This package follows Semantic Versioning:
- Patch (1.0.0 → 1.0.1): Bug fixes, no breaking changes
- Minor (1.0.0 → 1.1.0): New features, backward compatible
- Major (1.0.0 → 2.0.0): Breaking changes
Edit Directory.Build.props:
<Version>1.0.1</Version>
<AssemblyVersion>1.0.1.0</AssemblyVersion>
<FileVersion>1.0.1.0</FileVersion>Then rebuild and republish.
After publishing to NuGet:
-
Create a Git tag:
git tag -a v1.0.0 -m "Release version 1.0.0" git push origin v1.0.0 -
Go to GitHub → Releases → Create a new release
-
Select the tag you just created
-
Add release notes describing changes
-
Publish the release
Use environment variables or secret managers:
# Windows
$env:NUGET_API_KEY = "your-api-key"
dotnet nuget push ./artifacts/*.nupkg --api-key $env:NUGET_API_KEY --source https://api.nuget.org/v3/index.json
# Linux/Mac
export NUGET_API_KEY="your-api-key"
dotnet nuget push ./artifacts/*.nupkg --api-key $NUGET_API_KEY --source https://api.nuget.org/v3/index.jsonCreate a nuget.config in your home directory (NOT in the repository):
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<apikeys>
<add key="https://api.nuget.org/v3/index.json" value="YOUR_API_KEY" />
</apikeys>
</configuration>Then you can push without specifying the API key:
dotnet nuget push ./artifacts/*.nupkg --source https://api.nuget.org/v3/index.jsonBefore publishing a new version:
- Update version in
Directory.Build.props - Update
CHANGELOG.md(if you have one) - Run all tests:
dotnet test - Build in Release mode:
dotnet build -c Release - Test locally with a sample project
- Pack the package:
dotnet pack -c Release - Review the
.nupkgcontents - Commit changes and create a Git tag
- Push to GitHub
- Publish to NuGet.org
- Wait for indexing (5-15 minutes)
- Verify package appears on NuGet.org
- Create GitHub release with notes
- Announce the release (if applicable)
Before publishing, inspect what's in your package:
- Download from https://github.com/NuGetPackageExplorer/NuGetPackageExplorer
- Open your
.nupkgfile - Review contents, metadata, and dependencies
# Extract .nupkg (it's a zip file)
unzip MultiTenancy.EntityFrameworkCore.1.0.0.nupkg -d extracted/
# View contents
ls -R extracted/If you're contributing to this package:
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature - Make your changes
- Run tests:
dotnet test - Commit:
git commit -m "Add my feature" - Push:
git push origin feature/my-feature - Create a Pull Request
If you try to publish the same version twice:
error: Response status code does not indicate success: 409 (Conflict - The feed already contains 'MultiTenancy.EntityFrameworkCore' version '1.0.0'.)
Solution: Increment the version number. NuGet.org doesn't allow republishing the same version.
error: Response status code does not indicate success: 401 (Unauthorized)
Solutions:
- Verify your API key is correct
- Check that your API key has Push permissions
- Ensure the package name matches the glob pattern in your API key settings
Make sure symbols are enabled in Directory.Build.props:
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>- NuGet Documentation
- Creating NuGet Packages
- Publishing to NuGet.org
- Semantic Versioning
- .NET CLI Reference
- 🐛 Issues: GitHub Issues
- 💬 Discussions: GitHub Discussions
- 📦 NuGet: NuGet Package Page
Happy coding! 🚀