RulesEngine 5.0.3

dotnet add package RulesEngine --version 5.0.3
NuGet\Install-Package RulesEngine -Version 5.0.3
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="RulesEngine" Version="5.0.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add RulesEngine --version 5.0.3
#r "nuget: RulesEngine, 5.0.3"
#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.
// Install RulesEngine as a Cake Addin
#addin nuget:?package=RulesEngine&version=5.0.3

// Install RulesEngine as a Cake Tool
#tool nuget:?package=RulesEngine&version=5.0.3

Rules Engine

build Coverage Status Nuget download


Rules Engine is a library/NuGet package for abstracting business logic/rules/policies out of a system. It provides a simple way of giving you the ability to put your rules in a store outside the core logic of the system, thus ensuring that any change in rules don't affect the core system.


To install this library, download the latest version of NuGet Package from and refer it into your project.

How to use it

There are several ways to populate workflows for the Rules Engine as listed below.

You need to store the rules based on the schema definition given and they can be stored in any store as deemed appropriate like Azure Blob Storage, Cosmos DB, Azure App Configuration, Entity Framework, SQL Servers, file systems etc. For RuleExpressionType LambdaExpression, the rule is written as a lambda expressions.

An example rule:

    "WorkflowName": "Discount",
    "Rules": [
        "RuleName": "GiveDiscount10",
        "SuccessEvent": "10",
        "ErrorMessage": "One or more adjust rules failed.",
        "ErrorType": "Error",
        "RuleExpressionType": "LambdaExpression",
        "Expression": " == \"india\" AND input1.loyaltyFactor <= 2 AND input1.totalPurchasesToDate >= 5000"
        "RuleName": "GiveDiscount20",
        "SuccessEvent": "20",
        "ErrorMessage": "One or more adjust rules failed.",
        "ErrorType": "Error",
        "RuleExpressionType": "LambdaExpression",
        "Expression": " == \"india\" AND input1.loyaltyFactor >= 3 AND input1.totalPurchasesToDate >= 10000"

You can inject the rules into the Rules Engine by initiating an instance by using the following code -

var rulesEngine = new RulesEngine(workflow);

Here, workflow is a list of deserialized objects based on the schema explained above Once initialised, the Rules Engine needs to execute the rules for a given input. This can be done by calling the method ExecuteAllRulesAsync:

List<RuleResultTree> response = await rulesEngine.ExecuteAllRulesAsync(workflowName, input);

Here, workflowName is the name of the workflow, which is Discount in the above mentioned example. And input is the object which needs to be checked against the rules, which itself may consist of a list of class instances.

The response will contain a list of RuleResultTree which gives information if a particular rule passed or failed.

Note: A detailed example showcasing how to use Rules Engine is explained in Getting Started page of Rules Engine Wiki.

A demo app for the is available at this location.


A simple example via code only is as follows:

List<Rule> rules = new List<Rule>();

Rule rule = new Rule();
rule.RuleName = "Test Rule";
rule.SuccessEvent = "Count is within tolerance.";
rule.ErrorMessage = "Over expected.";
rule.Expression = "count < 3";
rule.RuleExpressionType = RuleExpressionType.LambdaExpression;

var workflows = new List<Workflow>();

Workflow exampleWorkflow = new Workflow();
exampleWorkflow.WorkflowName = "Example Workflow";
exampleWorkflow.Rules = rules;


var bre = new RulesEngine.RulesEngine(workflows.ToArray());

Entity Framework

Consuming Entity Framework and populating the Rules Engine is shown in the EFDemo class with Workflow rules populating the array and passed to the Rules Engine, The Demo App includes an example RulesEngineDemoContext using SQLite and could be swapped out for another provider.

var wfr = db.Workflows.Include(i => i.Rules).ThenInclude(i => i.Rules).ToArray();
var bre = new RulesEngine.RulesEngine(wfr, null);

Note: For each level of nested rules expected, a ThenInclude query appended will be needed as shown above.

How it works

alternate text is missing from this package README image

The rules can be stored in any store and be fed to the system in a structure which adheres to the schema of WorkFlow model.

A wrapper needs to be created over the Rules Engine package, which will get the rules and input message(s) from any store that your system dictates and put it into the Engine. The wrapper then handles the output using appropriate means.

Note: To know in detail of the workings of Rules Engine, please visit How it works section in Rules Engine Wiki.

3rd Party Tools

RulesEngine Editor

There is an editor library with it's own NuGet Package written in Blazor, more information is in it's repo

Live Demo

This can also be installed as a standalone PWA and used offline.

With Sample Data


This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact with any additional questions or comments.

For more details please check out Rules Engine Wiki.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (12)

Showing the top 5 NuGet packages that depend on RulesEngine:

Package Downloads



Editor for Microsoft RulesEngine - Blazor UI library intended for integration in Web or Desktop


this product is a lebrery to enhance the domain driven .net development


Package Description


Package Description

GitHub repositories (7)

Showing the top 5 popular GitHub repositories that depend on RulesEngine:

Repository Stars
Surging is a micro-service engine that provides a lightweight, high-performance, modular RPC request pipeline. support Event-based Asynchronous Pattern and reactive programming ,The service engine supports http, TCP, WS,Grpc, Thrift,Mqtt, UDP, and DNS protocols. It uses ZooKeeper and Consul as a registry, and integrates it. Hash, random, polling, Fair Polling as a load balancing algorithm, built-in service governance to ensure reliable RPC communication, the engine contains Diagnostic, link tracking for protocol and middleware calls, and integration SkyWalking Distributed APM
IoTSharp is an open-source IoT platform for data collection, processing, visualization, and device management.
这是基于vue-vben-admin 模板适用于abp Vnext的前端管理项目
.NET next-generation microservice development framework, which provides cloud native best practices based on Dapr.
Editor for Microsoft RulesEngine - Blazor UI library intended for integration in Web or Desktop
Version Downloads Last updated
5.0.3 227,673 1/12/2024
5.0.2 371,963 8/16/2023
5.0.1 118,922 7/12/2023
5.0.0 11,573 7/8/2023
4.0.0 1,219,758 10/2/2022
4.0.0-preview.1 11,458 4/25/2022
3.5.0 769,384 12/11/2021
3.4.0 84,880 10/1/2021
3.3.0 109,513 7/20/2021
3.2.0 94,578 6/8/2021
3.1.1 23,550 8/20/2021
3.1.0 52,436 4/28/2021
3.1.0-preview.4 200 4/19/2021
3.1.0-preview.3 5,138 3/8/2021
3.1.0-preview.2 182 3/2/2021
3.1.0-preview.1 3,883 2/2/2021
3.0.2 96,412 1/21/2021
3.0.1 12,862 12/23/2020
3.0.0 2,293 12/16/2020
3.0.0-preview.3 227 12/11/2020
3.0.0-preview.2 2,343 11/16/2020
3.0.0-preview.1 353 11/2/2020
2.1.5 61,940 11/2/2020
2.1.4 9,637 10/14/2020
2.1.3 4,029 10/12/2020
2.1.2 1,921 10/2/2020
2.1.1 26,185 9/1/2020
2.1.0 24,099 7/27/2020
2.0.0 115,287 5/18/2020
1.0.2 19,730 1/16/2020
1.0.1 2,192 9/24/2019
1.0.0 2,303 8/20/2019