Soenneker.GitHub.Repositories.Rulesets 4.0.1676

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Soenneker.GitHub.Repositories.Rulesets --version 4.0.1676
                    
NuGet\Install-Package Soenneker.GitHub.Repositories.Rulesets -Version 4.0.1676
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Soenneker.GitHub.Repositories.Rulesets" Version="4.0.1676" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.GitHub.Repositories.Rulesets" Version="4.0.1676" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.GitHub.Repositories.Rulesets" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Soenneker.GitHub.Repositories.Rulesets --version 4.0.1676
                    
#r "nuget: Soenneker.GitHub.Repositories.Rulesets, 4.0.1676"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Soenneker.GitHub.Repositories.Rulesets@4.0.1676
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Soenneker.GitHub.Repositories.Rulesets&version=4.0.1676
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.GitHub.Repositories.Rulesets&version=4.0.1676
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

alternate text is missing from this package README image Soenneker.GitHub.Repositories.Rulesets

Create, inspect, and remove repository-level GitHub rulesets for branches, tags, or pushes.

Installation

dotnet add package Soenneker.GitHub.Repositories.Rulesets

Configuration

{
  "GH": {
    "Token": "github-token"
  }
}

The token needs repository administration permission to create or delete rulesets.

Registration

services.AddGitHubRepositoriesRulesetsUtilAsSingleton();

Use AddGitHubRepositoriesRulesetsUtilAsScoped() for a scoped consumer.

Create a ruleset

var ruleset = new RepositoryRuleset
{
    Name = "Protect main",
    Target = TargetEnum.Branch,
    Enforcement = EnforcementEnum.Active,
    Conditions = new Conditions
    {
        RefName = new RefNameCondition
        {
            Include = ["refs/heads/main"]
        }
    },
    Rules =
    [
        new Rule { Type = "deletion" },
        new Rule { Type = "non_fast_forward" }
    ]
};

await rulesets.Add(
    "soenneker",
    "example-repository",
    ruleset,
    cancellationToken);

RepositoryRuleset maps directly to GitHub's ruleset request shape. Rule types and their Parameters must be valid for the selected target.

List or delete rulesets

List<RepositoryRuleset> existing = await rulesets.GetAll(
    "soenneker",
    "example-repository",
    cancellationToken);

await rulesets.Delete(
    "soenneker",
    "example-repository",
    rulesetId,
    cancellationToken);

GetAll follows pagination and returns all visible repository rulesets. DeleteAll permanently removes every ruleset returned for the repository; it does not preserve or recreate their policies.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Soenneker.GitHub.Repositories.Rulesets:

Package Downloads
Soenneker.GitHub.Repositories.Suite

Registers commonly used Soenneker GitHub repository services through one package

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
11.0.1779 142 11/19/2026
11.0.1778 56 11/19/2026
11.0.1777 48 11/19/2026
11.0.1776 66 11/19/2026
11.0.1775 57 11/19/2026
11.0.1774 54 11/18/2026
11.0.1773 56 11/18/2026
11.0.1772 50 11/18/2026
11.0.1771 69 11/18/2026
11.0.1767 81 11/18/2026
11.0.1766 276 11/15/2026
11.0.1765 113 11/15/2026
11.0.1764 115 11/15/2026
11.0.1763 169 11/15/2026
11.0.1762 96 11/14/2026
11.0.1761 437 11/11/2026
11.0.1760 108 11/11/2026
11.0.1759 115 11/11/2026
11.0.1758 110 11/11/2026
4.0.1676 107 10/12/2026
Loading failed

Update dependency Soenneker.Extensions.Object to 4.0.4395 (#2225)