feat: add NuGet package support#41
Conversation
- Add complete NuGet metadata (Authors, RepositoryUrl, PackageReadmeFile) to MiniPdf.csproj - Add nuget-publish.yml workflow: auto-publish to NuGet.org on GitHub release - Add pack verification step to CI build - Add NuGet install instructions to README Closes mini-software#5
There was a problem hiding this comment.
Pull request overview
Adds NuGet packaging and publishing automation for the MiniPdf library, enabling release-driven publishing to NuGet.org and CI verification that the project can be packed.
Changes:
- Added NuGet package metadata (authors, repo URLs, readme) to
MiniPdf.csprojand included the rootREADME.mdin the package. - Introduced a
nuget-publish.ymlworkflow to pack and push on GitHub Release publish. - Updated CI to run
dotnet packas a packaging sanity check, and updated README with NuGet install instructions.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/MiniPdf/MiniPdf.csproj |
Adds NuGet metadata and attempts to include the repository README in the produced package. |
README.md |
Documents installing MiniPdf from NuGet. |
.github/workflows/nuget-publish.yml |
Implements release-triggered pack + publish to NuGet.org. |
.github/workflows/ci.yml |
Adds a dotnet pack step to ensure packaging succeeds in CI. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <None Include="..\..\README.md" Pack="true" PackagePath="\" /> |
There was a problem hiding this comment.
PackagePath="\" uses a Windows-style separator and can end up creating an unexpected folder name inside the .nupkg on non-Windows platforms. For packing the README at the package root (to match PackageReadmeFile), use an empty PackagePath (or /) instead.
| <None Include="..\..\README.md" Pack="true" PackagePath="\" /> | |
| <None Include="..\..\README.md" Pack="true" PackagePath="" /> |
| - name: Extract version from tag | ||
| id: version | ||
| run: echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Pack | ||
| run: dotnet pack src/MiniPdf/MiniPdf.csproj --no-build --configuration Release -p:PackageVersion=${{ steps.version.outputs.VERSION }} --output ./nupkg |
There was a problem hiding this comment.
The workflow sets PackageVersion from the Git tag, but the PR description instructs maintainers to update <Version> in MiniPdf.csproj. As-is, those can diverge (CI packing uses the csproj version, while publishing uses the tag). Consider either (1) relying on the csproj <Version> and dropping the -p:PackageVersion=... override, or (2) adding a validation step that fails if the tag version doesn't match the csproj version, and update the publish instructions accordingly.
| run: echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT | ||
|
|
There was a problem hiding this comment.
VERSION=${GITHUB_REF_NAME#v} assumes the tag is prefixed with v and doesn't validate the result. If the release tag is missing the prefix (or is just v), the version passed to dotnet pack can become invalid/empty and fail in a confusing way. Consider adding a small validation step to assert the extracted version is non-empty and matches an expected NuGet/SemVer pattern before packing.
| run: echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT | |
| run: | | |
| RAW_TAG="${GITHUB_REF_NAME}" | |
| VERSION="${RAW_TAG#v}" | |
| if [ -z "$VERSION" ]; then | |
| echo "Error: Extracted version is empty. Ensure the release tag is of the form 'v<version>' (e.g., 'v1.2.3')." | |
| exit 1 | |
| fi | |
| if ! echo "$VERSION" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$'; then | |
| echo "Error: Extracted version '$VERSION' is not a valid SemVer/NuGet version (expected format: MAJOR.MINOR.PATCH[-PRERELEASE])." | |
| exit 1 | |
| fi | |
| echo "Using version: $VERSION" | |
| echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT" |
Summary
Add NuGet package publishing infrastructure for MiniPdf.
Changes
dotnet packverification step so every CI build ensures the package can be packed successfullydotnet add package MiniPdfinstall instructionsHow to publish a new version
<Version>insrc/MiniPdf/MiniPdf.csprojv0.2.0nuget-publish.ymlworkflow will automatically pack and push to NuGet.orgRequired secret
NUGET_API_KEY— NuGet.org API key with push permission for theMiniPdfpackageCloses #5