---
id: "M:cAlgo.API.Compiler.Compile(System.String)"
kind: "method"
type: "T:cAlgo.API.Compiler"
url: "https://help.ctrader.com/ctrader-algo/references/Compilation/Compiler/Compile/"
---

> Documentation index for agents: https://help.ctrader.com/ctrader-algo/llms.txt · machine index: https://help.ctrader.com/ctrader-algo/api.json

# Compiler.Compile

Member of [Compiler](https://help.ctrader.com/ctrader-algo/references/Compilation/Compiler/index.md).

## Compile(string csprojFilePath)

Compiles an algo.

Environments: Desktop supported · CLI supported · Cloud not supported.

- Cloud: Nothing is compiled. Compile returns a failed result with no errors; CompileAsync calls back asynchronously with that failed result.

C#:

```csharp
CompilationResult Compile(string csprojFilePath)
```

Python:

```python
api.Compiler.Compile(csprojFilePath: str) -> CompilationResult
```

### Parameters

- `csprojFilePath` (`string`, Python `str`): Algo project file path.

### Returns

`CompilationResult` — CompilationResult

Available since cAlgo.API 5.1.

### Examples

C#:

```csharp
var result = Compiler.Compile(@"Sample cBot\Sample cBot.csproj");
if (result.Succeeded)
    Print("Compilation succeeded");
else
    Print("Compilation failed: {0}", string.Join(", ", result.Errors));
```

Python:

```python
result = api.Compiler.Compile(r"Sample cBot\Sample cBot.csproj")
if result.Succeeded:
    api.Print("Compilation succeeded")
else:
    errors = ", ".join(result.Errors)
    api.Print(f"Compilation failed: {errors}")
```

## Compile(string csprojFilePath, CompilationOptions options)

Compiles an algo.

Environments: Desktop supported · CLI supported · Cloud not supported.

- Cloud: Nothing is compiled. Compile returns a failed result with no errors; CompileAsync calls back asynchronously with that failed result.

C#:

```csharp
CompilationResult Compile(string csprojFilePath, CompilationOptions options)
```

Python:

```python
api.Compiler.Compile(csprojFilePath: str, options: CompilationOptions) -> CompilationResult
```

### Parameters

- `csprojFilePath` (`string`, Python `str`): Algo project file path.
- `options` (`CompilationOptions`, Python `CompilationOptions`): Compilation options.

### Returns

`CompilationResult` — CompilationResult

Available since cAlgo.API 5.1.

### Examples

C#:

```csharp
var options = new CompilationOptions { IncludeSourceCode = true, OutputAlgoFilePath = @"C:\Algos\Sample cBot.algo" };
var result = Compiler.Compile(@"Sample cBot\Sample cBot.csproj", options);
Print("Compilation succeeded: {0}", result.Succeeded);
```

Python:

```python
options = CompilationOptions()
options.IncludeSourceCode = True
options.OutputAlgoFilePath = r"C:\Algos\Sample cBot.algo"
result = api.Compiler.Compile(r"Sample cBot\Sample cBot.csproj", options)
api.Print(f"Compilation succeeded: {result.Succeeded}")
```

