Skip to content

Scaffold .NET 8 class library with GitHub Packages publish workflow#1

Draft
kylemwhite with Copilot wants to merge 2 commits into
mainfrom
copilot/create-dotnet-class-library-scaffolding
Draft

Scaffold .NET 8 class library with GitHub Packages publish workflow#1
kylemwhite with Copilot wants to merge 2 commits into
mainfrom
copilot/create-dotnet-class-library-scaffolding

Conversation

Copilot AI commented Mar 14, 2026

Copy link
Copy Markdown

Adds the minimal repository scaffolding needed to build, pack, and publish a private NuGet package to GitHub Packages via GitHub Actions.

Added files

  • src/mdz-core/mdz-core.csproj — SDK-style .NET 8 class library placeholder. GeneratePackageOnBuild=false; version is injected at pack time via /p:Version=. Drop .cs source files into src/mdz-core/ and update Authors/Company metadata before first publish.

  • .github/workflows/publish.yml — CI/CD pipeline that triggers on push to main or any vX.Y.Z tag.

Workflow steps

Step Notes
Configure source Registers GitHub Packages endpoint using GITHUB_TOKEN; no nuget.org involvement
Version Strips v prefix from tag → semver; falls back to 1.0.0 on branch pushes
Build Release config, /p:Version= override
Test Skipped gracefully when no *Tests.csproj found under src/ or tests/
Pack Outputs to out/
Publish --skip-duplicate prevents re-publish failures on the same version
- name: Determine package version
  id: version
  run: |
    if [[ "${GITHUB_REF}" == refs/tags/v* ]]; then
      VERSION="${GITHUB_REF#refs/tags/v}"
    else
      VERSION="1.0.0"
    fi
    echo "VERSION=${VERSION}" >> "$GITHUB_OUTPUT"
Original prompt

You are assisting me in scaffolding a clean .NET class library repository that will publish a PRIVATE NuGet package to GitHub Packages. I already have the code for the DLL, so generate the scaffolding and workflows in a way that lets me drop my existing code into the right folders.

GOAL

Create a GitHub repository structure and a GitHub Actions workflow that:

  1. Builds a .NET class library
  2. Packs it into a .nupkg
  3. Publishes it to GitHub Packages as a PRIVATE package
  4. Uses GitHub Actions secrets for authentication
  5. Supports semantic versioning or auto-incrementing versions
  6. Does NOT require nuget.org publishing

REQUIREMENTS

  • Use .NET 8 for the library.

  • Create a folder structure like:

    /src/
    mdz-core/
    mdz-core.csproj <-- placeholder, I will replace with my real code

  • Create a GitHub Actions workflow at:
    .github/workflows/publish.yml

  • The workflow must:

    • Trigger on push to main AND on tags like v1.2.3
    • Restore, build, test (if tests exist), pack, and publish
    • Use GITHUB_TOKEN for publishing to GitHub Packages
    • Set the package source to: https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json
  • The workflow must include:

    • dotnet restore
    • dotnet build --configuration Release
    • dotnet pack --configuration Release -o out
    • dotnet nuget push out/*.nupkg --source "github" --api-key ${{ secrets.GITHUB_TOKEN }}
  • Generate a sample mdz-core.csproj that:

    • Uses SDK-style project format
    • Has placeholders for versioning
    • Has PackageId set to "mdz-core"
    • Has GeneratePackageOnBuild disabled (we will pack manually)

OUTPUT FORMAT

Provide:

  1. The full repo folder structure
  2. The mdz-core.csproj template
  3. The complete publish.yml GitHub Actions workflow
  4. A short note telling me where to paste my existing DLL code

Do NOT generate example code for the library itself — only scaffolding.


📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

Co-authored-by: kylemwhite <4984480+kylemwhite@users.noreply.github.com>
Copilot AI changed the title [WIP] Add scaffolding for .NET class library and workflow Scaffold .NET 8 class library with GitHub Packages publish workflow Mar 14, 2026
Copilot AI requested a review from kylemwhite March 14, 2026 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants