> ## Documentation Index
> Fetch the complete documentation index at: https://docs.shardcloud.app/llms.txt
> Use this file to discover all available pages before exploring further.

# C# Hosting Guide

> Learn how to deploy C# (.NET) applications on ShardCloud platform.

# Getting Started with C# Hosting

Deploy your C# (.NET) applications on ShardCloud with minimal configuration and maximum performance.

<Info>
  ShardCloud supports .NET applications with automatic build and execution via `dotnet run` or direct `.dll` execution.
</Info>

## Prerequisites

Before uploading your C# application, ensure you have the following project structure ready.

<CardGroup cols={2}>
  <Card title="Required Files" icon="circle">
    Essential files for deployment
  </Card>

  <Card title="Excluded Files" icon="x">
    Files to exclude before upload
  </Card>
</CardGroup>

## Required Files

Your C# application must include these essential files:

### 1. Project or Entry Point File

You can deploy using one of these options:

| MAIN Value      | Execution Command                   | Use Case                                     |
| --------------- | ----------------------------------- | -------------------------------------------- |
| `MyApp.csproj`  | `dotnet run --project MyApp.csproj` | Upload source code, platform builds and runs |
| `MyApp.dll`     | `dotnet MyApp.dll`                  | Upload pre-built DLL                         |
| `auto` or empty | Auto-detect `.dll` in `bin/` folder | Let platform find your DLL                   |
| *(omitted)*     | `dotnet run`                        | Run from project root                        |

### 2. ShardCloud Configuration

* **File**: `.shardcloud`
* **Purpose**: Platform-specific deployment settings
* **Requirements**: Plain text configuration file in root directory

<Warning>
  The `.shardcloud` file is required. Missing this file will prevent successful deployment.
</Warning>

## Deployment Options

### Option 1: Upload Source Code (Recommended)

Upload your source code with the `.csproj` file and let ShardCloud build and run it automatically.

**Required files:**

* `*.cs` source files
* `YourApp.csproj`
* `.shardcloud`

**Files to exclude:**

* `bin/`
* `obj/`
* `.vs/`
* `*.user`

### Option 2: Upload Pre-built DLL

Upload your compiled application directly.

**Required files:**

* `YourApp.dll` (and dependencies)
* `.shardcloud`

## ShardCloud Configuration

The [.shardcloud](/config) file configures your application deployment settings.

### Configuration Example (Source Code)

```bash theme={null}
DISPLAY_NAME=myfirstcsharpproject
DESCRIPTION=a simple C# application
MAIN=MyApp.csproj
MEMORY=1024
VERSION=recommended
```

### Configuration Example (Pre-built DLL)

```bash theme={null}
DISPLAY_NAME=myfirstcsharpproject
DESCRIPTION=a simple C# application
MAIN=MyApp.dll
MEMORY=1024
VERSION=recommended
```

<Note>
  .NET applications typically require more memory than interpreted languages. Choose appropriate memory allocation for your application's needs.
</Note>

## Deployment Process

<Steps>
  <Step title="Prepare Application">
    Ensure your project compiles locally with `dotnet build`
  </Step>

  <Step title="Create Configuration">
    Create `.shardcloud` file with deployment settings
  </Step>

  <Step title="Exclude Unnecessary Files">
    Remove `bin/`, `obj/`, and `.vs/` folders (if uploading source)
  </Step>

  <Step title="Create Archive">
    Zip or RAR your project
  </Step>

  <Step title="Upload via Dashboard">
    Use [ShardCloud dashboard](https://shardcloud.app/dash) to upload your archive
  </Step>

  <Step title="Deploy & Monitor">
    Application automatically builds (if needed) and runs
  </Step>
</Steps>

## Common Configuration Examples

### ASP.NET Core Web API

```bash theme={null}
DISPLAY_NAME=aspnet-api
DESCRIPTION=REST API with ASP.NET Core
MAIN=MyApi.csproj
MEMORY=1024
VERSION=recommended
SUBDOMAIN=aspnetapi
```

### Console Application

```bash theme={null}
DISPLAY_NAME=dotnet-worker
DESCRIPTION=Background worker service
MAIN=Worker.csproj
MEMORY=512
VERSION=recommended
```

### Pre-built Application

```bash theme={null}
DISPLAY_NAME=dotnet-app
DESCRIPTION=Pre-compiled .NET application
MAIN=MyApp.dll
MEMORY=512
VERSION=recommended
```
