Skip to content
Latchkey

actions/setup-dotnet: Install the .NET SDK in CI

setup-dotnet installs the .NET SDK version(s) your project needs.

Pin one or several SDK versions, or read global.json. Optionally configure a NuGet source for restoring or publishing packages.

Key inputs (with:)

  • dotnet-version: one or more SDK versions, e.g. 8.0.x.
  • global-json-file: read the SDK version from global.json.
  • source-url: a NuGet feed to authenticate against.
  • cache: enable NuGet package caching.

Example workflow

.github/workflows/ci.yml
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-dotnet@v4
        with:
          dotnet-version: 8.0.x
      - run: dotnet restore
      - run: dotnet test

On any runner

setup-dotnet runs on any runner. Latchkey managed runners run it unchanged.

Key takeaways

  • You can install multiple SDK versions at once.
  • global-json-file keeps CI pinned to your repo SDK.
  • source-url plus a token enables NuGet publishing.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →