This document explains how to publish the PanoramicData.SheetMagic package to NuGet.org.
- PowerShell 7.0+ - The publish script requires PowerShell 7 or later
- NuGet API Key - You need a valid NuGet.org API key
- Git - A clean working directory (no uncommitted changes)
- .NET 9 SDK - To build and test the project
- Go to https://www.nuget.org/account/apikeys
- Sign in with your NuGet.org account
- Create a new API key with the following settings:
- Key Name:
PanoramicData.SheetMagic - Package Owner: Select your account
- Scopes: Select "Push" and "Push new packages and package versions"
- Packages: Select "Only selected packages" and choose
PanoramicData.SheetMagic - Expiration: Set an appropriate expiration date
- Key Name:
Add your API key to the nuget-key.txt file in the root directory:
your-api-key-here
?? IMPORTANT: This file is already in .gitignore. Never commit your API key to source control!
To publish with all safety checks:
.\Publish.ps1This will:
- ? Check Git status (must be clean)
- ? Run all unit tests
- ? Build and pack the project
- ? Prompt for confirmation
- ? Publish to NuGet.org
To test the script without actually publishing:
.\Publish.ps1 -DryRunTo skip unit tests (use only in exceptional circumstances):
.\Publish.ps1 -SkipTestsEnsures your working directory is clean with no uncommitted changes. This guarantees that the published package matches a specific commit in your repository.
Runs all tests in Release configuration to ensure the package works correctly.
Builds the project in Release configuration and creates the NuGet package (.nupkg file).
Pushes the package to NuGet.org. The --skip-duplicate flag prevents errors if the version already exists.
The project uses Nerdbank.GitVersioning for automatic version management. The version is determined by:
- Git tags
- Commit height
- Branch name
- Configuration in
version.json
-
Create a version tag:
git tag v1.2.3 git push origin v1.2.3
-
Ensure clean state:
git status
-
Publish:
.\Publish.ps1
- Commit or stash your changes before publishing
- Use
git statusto see what's uncommitted
- Fix the failing tests before publishing
- Review test output for details
- Use
-SkipTestsonly if absolutely necessary (not recommended)
- Ensure
nuget-key.txtexists in the root directory - Add your API key to the file
- Check if the version already exists on NuGet.org
- Verify your API key has the correct permissions
- Ensure you have internet connectivity
- Check the build output for errors
- Ensure the project builds successfully
- Look in
PanoramicData.SheetMagic\bin\Releasefor .nupkg files
- ?
nuget-key.txtis in.gitignore - ? The script clears the API key from memory after use
- ? Never commit API keys to source control
- ? Rotate API keys periodically
- ? Use scoped API keys (only for this package)
- Always ensure tests pass before publishing
- Always commit your changes before publishing
- Tag releases for version tracking
- Update package release notes in the .csproj file
- Test in a staging environment if possible
- Review the package contents before publishing
- Monitor NuGet.org after publishing to ensure the package appears