> For the complete documentation index, see [llms.txt](https://docs.appstrategy.com/apprules-r-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.appstrategy.com/apprules-r-documentation/platform/self-hosting/software-installation/hostservice.md).

# Self-Hosted Server Settings

Starting with appRulesPortal v9.0 (Wisej 4), the former `appRules.HostService.exe` has been replaced by the **appRulesPortal kernel engine** — a self-hosted [Kestrel](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel) Windows Service that runs natively without IIS.

The portal now runs as **four coordinated Windows Services** that must all be installed and started together.

> **Note:** IIS is not required. See IIS Settings if you want to put IIS in front of Kestrel as a reverse proxy for SSL termination or port 80/443 routing.

***

#### Prerequisites

| Requirement     | Details                                                                                                                               |
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| OS              | Windows Server 2019 / 2022 and higher                                                                                                 |
| .NET 10 Runtime | ASP.NET Core Runtime 10.x **and** .NET 10 Desktop Runtime (x64) — [Download](https://dotnet.microsoft.com/en-us/download/dotnet/10.0) |
| Garnet/Redis    | Required by `appRules.CachingService`                                                                                                 |
| SQL Server      | Required for the appRules metadata database                                                                                           |

Both .NET 10 runtimes are required: the ASP.NET Core runtime for the Kestrel host and the Web API, and the Desktop runtime for the Wisej.NET UI framework. Installing the **.NET 10 Hosting Bundle** provides the ASP.NET Core runtime and the IIS module; the Desktop Runtime is a separate download. See Installation Prerequisites.

Verify with:

```bat
dotnet --list-runtimes
```

`Microsoft.NETCore.App`, `Microsoft.AspNetCore.App` and `Microsoft.WindowsDesktop.App` must each show a 10.x version.

***

#### The Four Services

| Service Executable              | Display Name               | Role                                            |
| ------------------------------- | -------------------------- | ----------------------------------------------- |
| `appRulesPortal.exe`            | appRules Portal            | Kestrel web host — serves the Wisej application |
| `appRules.CachingService.exe`   | appRules Caching Service   | Redis-backed session and data cache             |
| `appRules.WebApiService.exe`    | appRules WebApi Service    | REST API layer                                  |
| `appRules.SchedulerService.exe` | appRules Scheduler Service | Background job scheduler                        |

All four executables are located in the `bin\` subfolder of the install directory (e.g. `[InstallationPath]\bin\`).

where \[InstallationPath]= appRulesPortal Folder Path

`appRules.CachingService` starts and supervises a fifth process, `GarnetServer.exe`, from `[InstallationPath]\Tools\appRulesCaching\bin\`. It is started when the service starts and stopped when the service stops; it is not registered as a Windows Service of its own.

***

#### Command-Line Arguments

**`appRulesPortal.exe`**

The portal executable uses standard ASP.NET Core hosting arguments:

| Argument                       | Description                                                                                                                                          |
| ------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--urls http://0.0.0.0:{port}` | Sets the listening URL and port. Default port is **8080**. Use `0.0.0.0` to accept all connections, or `localhost` to accept local connections only. |
| `--environment Production`     | Sets the runtime environment. Equivalent to `ASPNETCORE_ENVIRONMENT=Production`.                                                                     |

**Example — listen on all interfaces, port 8080:**

```bat
appRulesPortal.exe --urls http://0.0.0.0:8080
```

**Example — local connections only, custom port:**

```bat
appRulesPortal.exe --urls http://localhost:9000
```

> The companion services (`CachingService`, `WebApiService`, `SchedulerService`) take no command-line arguments. All their configuration is via `appsettings.json` / `appRules.WebApiService.appsettings.json`.

***

#### Service Registration

**Automated**

Use the provided PowerShell deployment script to install, configure, and start all four services in one step:

```powershell
# Deploy from Release folder to [InstallationPath] (default)
.\deploy_appRulesPortal.ps1

# Deploy to a custom path and port
.\deploy_appRulesPortal.ps1 -TargetDir "E:\appRulesPortal" -Port 8081
```

The script verifies that the .NET 10 runtimes are installed, registers all services, sets `ASPNETCORE_ENVIRONMENT=Production`, and starts them in the correct order.

**Manual**

Register each service using `sc.exe`. All executables must use their **full path**:

```bat
set INSTALL_DIR=[InstallationPath]
set BIN_DIR=%INSTALL_DIR%\bin

sc.exe create "appRulesPortal" binPath= "\"%BIN_DIR%\appRulesPortal.exe\" --urls http://0.0.0.0:8080" DisplayName= "appRules Portal" start= auto
sc.exe create "appRules.CachingService" binPath= "\"%BIN_DIR%\appRules.CachingService.exe\"" DisplayName= "appRules Caching Service" start= auto
sc.exe create "appRules.WebApiService" binPath= "\"%BIN_DIR%\appRules.WebApiService.exe\"" DisplayName= "appRules WebApi Service" start= auto
sc.exe create "appRules.SchedulerService" binPath= "\"%BIN_DIR%\appRules.SchedulerService.exe\"" DisplayName= "appRules Scheduler Service" start= auto
```

Set `ASPNETCORE_ENVIRONMENT=Production` for each service via the registry:

```bat
reg add "HKLM\SYSTEM\CurrentControlSet\Services\appRulesPortal" /v Environment /t REG_MULTI_SZ /d "ASPNETCORE_ENVIRONMENT=Production" /f
reg add "HKLM\SYSTEM\CurrentControlSet\Services\appRules.CachingService" /v Environment /t REG_MULTI_SZ /d "ASPNETCORE_ENVIRONMENT=Production" /f
reg add "HKLM\SYSTEM\CurrentControlSet\Services\appRules.WebApiService" /v Environment /t REG_MULTI_SZ /d "ASPNETCORE_ENVIRONMENT=Production" /f
reg add "HKLM\SYSTEM\CurrentControlSet\Services\appRules.SchedulerService" /v Environment /t REG_MULTI_SZ /d "ASPNETCORE_ENVIRONMENT=Production" /f
```

**Starting and stopping**

Services must be started in order — the portal depends on the three companion services being ready. Start `appRules.CachingService` first: it launches `GarnetServer.exe` before reporting *Running*, so the other services find the cache available instead of falling back to an in-memory cache.

```bat
REM Start
sc.exe start "appRules.CachingService"
sc.exe start "appRules.WebApiService"
sc.exe start "appRules.SchedulerService"
sc.exe start "appRulesPortal"

REM Stop (reverse order)
sc.exe stop "appRulesPortal"
sc.exe stop "appRules.SchedulerService"
sc.exe stop "appRules.WebApiService"
sc.exe stop "appRules.CachingService"
```

After stopping `appRules.CachingService`, confirm that no `GarnetServer.exe` process remains (Task Manager, or `tasklist | findstr GarnetServer`). A leftover process keeps port 6379 open and prevents the service from starting again.

**Uninstalling**

```bat
sc.exe delete "appRulesPortal"
sc.exe delete "appRules.CachingService"
sc.exe delete "appRules.WebApiService"
sc.exe delete "appRules.SchedulerService"
```

***

#### Configuration Files

| File                                      | Location              | Purpose                                         |
| ----------------------------------------- | --------------------- | ----------------------------------------------- |
| `appsettings.json`                        | `[InstallationPath]\` | ASP.NET Core connection strings and settings    |
| `appsettings.Production.json`             | `[InstallationPath]\` | Production overrides (merged at runtime)        |
| `appRules.WebApiService.appsettings.json` | `bin\`                | WebApi service endpoint configuration           |
| `Default.json`                            | `[InstallationPath]\` | Wisej license key, default theme, startup class |

**Minimum `appsettings.json`:**

```json
{
  "ConnectionStrings": {
    "DefaultConnection": "Server=.;Database=appRules;Trusted_Connection=True;TrustServerCertificate=True;"
  }
}
```

**Minimum `Default.json` settings to verify:**

* `Wisej.LicenseKey` — production license key
* `Wisej.DefaultTheme` — e.g. `appStrategy`
* `startup` — must be `"appStrategy.appRulesPortal.Program.WisejInit, appRulesPortal"`

***

#### Changing the Port

Pass a different `--urls` argument when registering the service:

```bat
sc.exe create "appRulesPortal" binPath= "\"[InstallationPath]\bin\appRulesPortal.exe\" --urls http://0.0.0.0:9000" DisplayName= "appRules Portal" start= auto
```

To change the port on an already-registered service, delete and re-create it, or use `sc.exe config`:

```bat
sc.exe config "appRulesPortal" binPath= "\"[InstallationPath]\bin\appRulesPortal.exe\" --urls http://0.0.0.0:9000"
```

***

#### Post-Installation Verification

| Check                      | Command / How                                                                                  |
| -------------------------- | ---------------------------------------------------------------------------------------------- |
| .NET 10 runtimes installed | `dotnet --list-runtimes` — 10.x entries for NETCore.App, AspNetCore.App and WindowsDesktop.App |
| All services running       | `sc.exe query appRulesPortal` — should show `RUNNING`                                          |
| Caching engine running     | `tasklist \| findstr GarnetServer` — one process                                               |
| Portal accessible          | Browse to `http://server:8080/` — should show login page                                       |
| WebSocket active           | Browser DevTools → Network → WS: `101 Switching Protocols`                                     |
| deps.json patched          | `findstr "runtimes/win" bin\*.deps.json` returns nothing                                       |
| JSON files blocked         | `GET /appsettings.json` returns HTTP 403                                                       |

***

#### Troubleshooting

| Error                                                       | Cause                                                       | Fix                                                                                                                              |
| ----------------------------------------------------------- | ----------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
| Service starts then immediately stops                       | Startup exception                                           | Check Windows Event Log: `eventvwr.msc` → Windows Logs → Application                                                             |
| `You must install .NET to run this application`             | .NET 10 runtime missing                                     | Install the .NET 10 Hosting Bundle **and** the .NET 10 Desktop Runtime (x64)                                                     |
| Portal not accessible on port 8080                          | Firewall blocking port                                      | `netsh advfirewall firewall add rule name="appRules" dir=in action=allow protocol=TCP localport=8080`                            |
| JS / static assets not loading                              | `staticwebassets.runtime.json` `ContentRoots` path wrong    | Patch the `bin\` file manually to the correct install path                                                                       |
| Access Denied on start                                      | Service account lacks folder permissions                    | Grant the service account (e.g. `LocalSystem`) read/write access to `[InstallationPath]\`                                        |
| Caching service starts but the cache is not used            | `GarnetServer.exe` not running, or port 6379 already in use | Check `Tools\appRulesCaching\bin\GarnetServer.exe` exists and is a .NET 10 build; check for a leftover process holding port 6379 |
| `appRules.CachingService` will not start again after a stop | Orphaned `GarnetServer.exe` holding port 6379               | End the process, then start the service                                                                                          |

***

***

***


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.appstrategy.com/apprules-r-documentation/platform/self-hosting/software-installation/hostservice.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
