Skip to content

credfeto/credfeto-dotnet-repo-tools

Repository files navigation

credfeto-dotnet-repo-tools

Dotnet/C# repository tools

Running (Package Update)

Updates all the packages specified in the packages.json file in the repositories in repos.txt.

  • release.json defines the configuration for generating releases when multiple packages have been updated
  • the template repo specified by --template is excluded from repos.txt if it is present
dotnet updaterepo \
    update-packages \
    --repositories ~/work/personal/auto-update-config/personal/repos.lst \
    --work ~/temp \
    --tracking ~/temp/tracking.json \
    --cache ~/temp/cache.json \
    --packages ~/work/personal/auto-update-config/packages.json \
    --template git@github.com:credfeto/cs-template.git \
    --release ~/work/personal/auto-update-config/release.json

Running (Template Update)

Updates common files in a repository to match the files defined template repository specified by --template.

dotnet updaterepo \
    update-template \
    --repositories ~/work/personal/auto-update-config/personal/repos.lst \
    --work ~/temp \
    --tracking ~/temp/tracking.json \
    --packages ~/work/personal/auto-update-config/packages.json \
    --template git@github.com:credfeto/cs-template.git \
    --release ~/work/personal/auto-update-config/release.json

Running (Code Cleanup)

TODO - this is not yet implemented

dotnet updaterepo \
    code-cleanup \
    --repositories ~/work/personal/auto-update-config/personal/repos.lst \
    --work ~/temp \
    --tracking ~/temp/tracking.json

cscleanup — Standalone C# Formatter

cscleanup is a standalone dotnet tool that formats C# source files (.cs) and project files (.csproj) without requiring a git repository or making any commits. It is suitable for use as a pre-commit hook or in CI pipelines.

Installation

dotnet tool install --global Credfeto.DotNet.Repo.Formatter

Usage

cscleanup [--remove-suppressions] [--build-root <path>] <inputs...>
Argument / Option Required Description
inputs Yes One or more files, glob patterns, or folders to process
--remove-suppressions No Remove redundant [SuppressMessage] attributes (requires --build-root)
--build-root <path> Conditional Root directory used for dotnet build when --remove-suppressions is enabled

Input resolution

  • File path — processed directly; must be a .cs or .csproj file
  • Glob pattern — expanded relative to the current working directory (e.g. "src/**/*.cs")
  • Directory — scanned recursively for all .cs and .csproj files, excluding generated files (paths containing /obj/, /generated/, or .generated. in the filename)

Passing any other file type is an error.

Examples

Format a single file:

cscleanup src/MyProject/Foo.cs

Format all C# files in a folder:

cscleanup src/MyProject/

Format files matching a glob:

cscleanup "src/**/*.cs"

Format multiple inputs at once:

cscleanup src/MyProject/ src/MyProject.Tests/

Remove suppression attributes (requires a successful build to verify each removal is safe):

cscleanup --remove-suppressions --build-root /path/to/solution src/MyProject/

What it does

For each .cs file:

  1. Converts Resharper suppression comments to [SuppressMessage] attributes
  2. Removes XML doc comments
  3. Reformats the file using CSharpier
  4. Optionally removes redundant [SuppressMessage] attributes (only when --remove-suppressions and --build-root are set)

For each .csproj file:

  1. Reorders <PropertyGroup> elements into a canonical order
  2. Reorders <ItemGroup> includes into a canonical order

Use as a pre-commit hook

Add to .git/hooks/pre-commit (or via a hook manager such as pre-commit):

#!/bin/sh
git diff --cached --name-only --diff-filter=ACM | grep -E '\.(cs|csproj)$' | xargs cscleanup

File formats

repos.lst

One line per repo to process e.g:

git@github.com:credfeto/repo1.git
git@github.com:credfeto/repo2.git
git@github.com:credfeto/repo3.git

tracking.json

This is generated by the tool

cache.json

This is generated by the tool

packages.json

TODO

release.json

TODO

GitHub Labels

The update-template command generates two GitHub configuration files for each managed repository:

  • labels.yml — defines all labels (name, colour, description) used in the repository
  • labeler.yml — maps file path patterns to labels so pull requests are labelled automatically

Static labels

These labels are applied to every managed repository regardless of content:

Label Colour Description
.NET update a870c9 Update to .NET SDK version in global.json
AI-Work ffa500 Work for an AI Agent
auto-pr 0000aa Pull request created automatically
Bug d73a4a Generic bug fix
C# db6baa C# source files
C# Project db6baa C# project files (.csproj)
C# Solution db6baa C# solution files (.sln / .slnx)
Change Log 53fcd4 Changelog tracking file
Changelog Not Required 08f5f8 No changelog entry required for this pull request
Config Change d8bb50 Configuration file changes
dependencies 0366d6 Updates to dependencies
DO NOT MERGE ff0000 This pull request should not be merged yet
dotnet db6baa .NET package updates
Editorconfig 00dead Editor config file change
Enhancement a2eeef Enhancement to project
github-actions e09cf4 GitHub Actions workflow files
High ffa500 High priority
Low cc8899 Low priority
Markdown 5319e7 Markdown files
Medium ffff00 Medium priority
Migration Script b680e5 SQL migration scripts
no-pr-activity ffff00 Pull request has had no activity for a long time
npm e99695 npm package update
On Hold ff0000 Do not work on this
Performance 0075ca Performance enhancement or issue
Powershell 23bc12 PowerShell source files
Read Me 5319e7 Repository readme file
Security ee0701 Security issue, e.g. use of insecure packages, or security fix
Setup 5319e7 Setup instructions
Solidity 413cd1 Solidity source files
SQL 413cd1 SQL source files
Static Code Analysis Rules 00dead Static code analysis ruleset files
Tech Debt 30027a Technical debt
Unit Tests 0e8a16 Unit test and integration test projects
Urgent ff0000 Urgent priority

Dynamic labels (per project)

For each .csproj found in the repository, a label is created named after the project (dots and spaces replaced with hyphens, lowercased). The colour indicates the project type:

Pattern Colour Meaning
*.Tests / *.Tests.* 0e8a16 Test project
*.Mocks 0e8a16 Mock/test-helper project
Everything else 96f7d2 Production source project

Build Status

Branch Status
main Build: Pre-Release
release Build: Release

Changelog

View changelog

Contributors

About

DotNet / C# repo bulk update tools

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Sponsor this project

  •  

Packages

 
 
 

Contributors

Languages

Generated from credfeto/cs-template