Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
alert-circle

GitHub Action

.NET version sweeper

v1.0

.NET version sweeper

alert-circle

.NET version sweeper

A Github action that scans .NET projects, and creates issues that report versions that are not within long term support

Installation

Copy and paste the following snippet into your .yml file.

              

- name: .NET version sweeper

uses: dotnet/[email protected]

Learn more about this action in dotnet/versionsweeper

Choose a version

🎯 LTS (or current) versions

.NET version sweeper

build & test target supported version code-ql analysis

Get started

The .NET version sweeper is designed to alert repositories that there are projects targeting versions that are no longer supported. For example, projects targeting .NET Core 3.0, or .NET Framework 4.5.1 would trigger an issue to be created to update these non-LTS or current versions. For example issues, see issues created in this repo based on the non-lts directory.

This is intended to be used as a GitHub action that will run as a scheduled CRON job. Ideally, once a month or as often as necessary to align with .NET version updates.

A schedule/cron job that runs on the first of every month is detailed below in the example workflow, '0 0 1 * *'.

Required inputs

Option Details
-o, owner The owner of the repo.
Assign from ${{ github.repository_owner }}. Example, "dotnet".
-n, name The repository name.
Assign from ${{ github.repository }}. Example, "dotnet/samples".
-b, branch The branch name.
Assign from ${{ github.ref }}. Example, "main".
-t, token The GitHub personal-access token (PAT), or the token from GitHub action context.
Assign from ${{ github.token }}.

Optional inputs

Option Details
-d, dir The root directory, defaults to "/github/workspace".
-p, pattern The search pattern, defaults to "*.csproj;*.fsproj;*.vbproj".
-s, sdk-compliance Whether or not to report projects that are not using the new SDK-style project format.

Example workflow

# The name used in the GitHub UI for the workflow
name: '.net version sweeper'

# When to run this action:
# - Scheduled on the first of every month
# - Manually runable from the GitHub UI with a reason
on:
  schedule:
  - cron: '0 0 1 * *'
  workflow_dispatch:
    inputs:
      reason:
        description: 'The reason for running the workflow'
        required: true
        default: 'Manual run'

# Run on the latest version of Ubuntu
jobs:
  version-sweep:
    runs-on: ubuntu-latest

    # Checkout the repo into the workspace within the VM
    steps:
    - uses: actions/checkout@v2

    # If triggered manually, print the reason why
    - name: 'Print manual run reason'
      if: ${{ github.event_name == 'workflow_dispatch' }}
      run: |
        echo "Reason: ${{ github.event.inputs.reason }}"

    # Run the .NET version sweeper
    # Issues will be automatically created for any non-ignored projects that are targeting non-LTS versions
    - name: .NET version sweeper
      id: dotnet-version-sweeper
      uses: ./
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        owner: ${{ github.repository_owner }}
        name: ${{ github.repository }}
        branch: ${{ github.ref }}
        sdkCompliance: true

Configure action

To configure the action, you can create a file at the root of the repository named dotnet-versionsweeper.json. This config file contains a node, named "ignore" that is an array of patterns following the globbing matcher detailed here.

{
  "ignore": [
    "**/SomePath/**/*.csproj",
    "**/*ThisShouldNeverBeFlagged.csproj",
    "IgnoreDir/**/*.*"
  ]
}

For an example config file, see dotnet/samples/dotnet-versionsweeper.json.

Label auto-generation

This tool will create a label named dotnet-target-version for easier tracking of issues and pull requests that it creates. The label is created with the following description and color by default, please do not change the name - as that is what is used to determine whether or not to create a new label.

Example labels in the wild

Example issues

This repo serves as a sample, as it contains a directory non-lts with projects and solutions that are intentionally targeting unsupported versions. There are issues created against these to exemplify how they render. For more information, see these issues.

Acknowledgements

Name NuGet package URL & license
CommandLineParser https://www.nuget.org/packages/CommandLineParser (MIT)
MarkdownBuilder https://www.nuget.org/packages/MarkdownBuilder (MIT)
Octokit https://www.nuget.org/packages/Octokit (MIT)
Octokit.Extensions https://www.nuget.org/packages/Octokit.Extensions (MIT)