A reusable workflow for checking the format of .NET projects.
Add a new workflow under .github/workflows with the following contents,
name: Continuous Integration
on:
push:
branches: [ master, dev ]
pull_request:
branches: [ master, dev ]
jobs:
format:
uses: Arthri/format-dotnet/.github/workflows/i.yml@v1
permissions:
contents: readThe workflow, by default, runs on Ubuntu 24.04 (as of April 09, 2025). The machine that the workflow runs on can be changed by using the runs-on input parameter.
jobs:
format:
uses: Arthri/format-dotnet/.github/workflows/i.yml@v1
with:
runs-on: windows-2022The workflow uses actions/setup-dotnet under the hood to setup the .NET environment. The workflow supports overriding the .NET version restored through the dotnet-version input parameter, corresponding to the parameter of the same name of actions/setup-dotnet.
The workflow has a default timeout of 5 minutes, which can be changed by setting the timeout-minutes input parameter.
jobs:
format:
uses: Arthri/format-dotnet/.github/workflows/i.yml@v1
with:
# Set the timeout back to the GitHub default of 30 minutes
timeout-minutes: 30Additional arguments can be passed to the dotnet format command using the format-arguments input parameter.
jobs:
format:
uses: Arthri/format-dotnet/.github/workflows/i.yml@v1
with:
# Exclude the file "Imports.g.cs" from formatting
format-arguments: --exclude Imports.g.cs