Skip to content

Compiler.Compile

method · Compiler · cAlgo.API Since 5.1

DesktopCLICloud

Compiles an algo.

Environment behaviour

Cloud — not supported. Nothing is compiled. Compile returns a failed result with no errors; CompileAsync calls back asynchronously with that failed result.

Overloads

Compile(string csprojFilePath)

Compiles an algo.

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

Parameters

Name C# type Python type Description
csprojFilePath string str Algo project file path.

Returns CompilationResult — CompilationResult

Examples

var result = Compiler.Compile(@"Sample cBot\Sample cBot.csproj");
if (result.Succeeded)
    Print("Compilation succeeded");
else
    Print("Compilation failed: {0}", string.Join(", ", result.Errors));
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.

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

Parameters

Name C# type Python type Description
csprojFilePath string str Algo project file path.
options CompilationOptions CompilationOptions Compilation options.

Returns CompilationResult — CompilationResult

Examples

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);
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}")