Note: GitHub-hosted runners are not currently supported on GitHub Enterprise Server. You can see more information about planned future support on the GitHub public roadmap.
Introduction
This guide shows you how to build, test, and publish a .NET package.
GitHub-hosted runners have a tools cache with preinstalled software, which includes the .NET Core SDK. For a full list of up-to-date software and the preinstalled versions of .NET Core SDK, see software installed on GitHub-hosted runners.
Prerequisites
You should already be familiar with YAML syntax and how it's used with GitHub Actions. For more information, see "Workflow syntax for GitHub Actions."
We recommend that you have a basic understanding of the .NET Core SDK. For more information, see Getting started with .NET.
Using a .NET starter workflow
To get started quickly, add a starter workflow to the .github/workflows directory of your repository.
GitHub provides a starter workflow for .NET that should work for most .NET projects. The subsequent sections of this guide give examples of how you can customize this starter workflow.
-
On your GitHub Enterprise Server instance, navigate to the main page of the repository.
-
Under your repository name, click Actions.

-
If you already have a workflow in your repository, click New workflow.
-
The "Choose a workflow" page shows a selection of recommended starter workflows. Search for "dotnet".
-
On the ".NET" workflow, click Configure.
If you don't find the ".NET" starter workflow, copy the following workflow code to a new file called
dotnet.ymlin the.github/workflowsdirectory of your repository.YAML name: .NET on: push: branches: [ "main" ] pull_request: branches: [ "main" ] jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Setup .NET uses: actions/setup-dotnet@v3 with: dotnet-version: 6.0.x - name: Restore dependencies run: dotnet restore - name: Build run: dotnet build --no-restore - name: Test run: dotnet test --no-build --verbosity normalname: .NET on: push: branches: [ "main" ] pull_request: branches: [ "main" ] jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Setup .NET uses: actions/setup-dotnet@v3 with: dotnet-version: 6.0.x - name: Restore dependencies run: dotnet restore - name: Build run: dotnet build --no-restore - name: Test run: dotnet test --no-build --verbosity normal -
Edit the workflow as required. For example, change the .NET version.
-
Click Commit changes.
Specifying a .NET version
To use a preinstalled version of the .NET Core SDK on a GitHub-hosted runner, use the