Soenneker.GitHub.Repositories.Rulesets 4.0.1659

Prefix Reserved
dotnet add package Soenneker.GitHub.Repositories.Rulesets --version 4.0.1659
                    
NuGet\Install-Package Soenneker.GitHub.Repositories.Rulesets -Version 4.0.1659
                    
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.1659" />
                    
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.1659" />
                    
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.1659
                    
#r "nuget: Soenneker.GitHub.Repositories.Rulesets, 4.0.1659"
                    
#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.1659
                    
#: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.1659
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.GitHub.Repositories.Rulesets&version=4.0.1659
                    
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
4.0.1659 54 9/26/2026
4.0.1657 46 9/26/2026
4.0.1656 47 9/26/2026
4.0.1651 111 9/24/2026
4.0.1649 45 9/24/2026
4.0.1648 45 9/24/2026
4.0.1647 43 9/24/2026
4.0.1646 69 9/24/2026
4.0.1645 56 9/24/2026
4.0.1644 45 9/24/2026
4.0.1643 393 9/18/2026
4.0.1642 161 9/17/2026
4.0.1641 92 9/17/2026
4.0.1640 112 9/16/2026
4.0.1639 117 9/16/2026
4.0.1638 114 9/16/2026
4.0.1637 99 9/16/2026
4.0.1636 136 9/16/2026
4.0.1635 137 9/15/2026
4.0.1634 88 9/15/2026
Loading failed

Update dependency Soenneker.Extensions.HttpResponseMessage to 4.0.2549 (#2183)