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 testOn 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
actions/checkout: Inputs & Workflow UsageReference for actions/checkout: clone your repository into the runner, control fetch-depth, submodules, refs,…
actions/cache: Save & Restore Build CachesReference for actions/cache: cache dependencies and build outputs across runs using key and restore-keys, wit…
codecov/codecov-action: Upload Coverage ReportsReference for codecov/codecov-action: upload test coverage reports to Codecov with a token, flags, and file p…