Build from terminal/command line

Created at 20 May 2021, 12:48
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
AM

amml

Joined 27.04.2021

Build from terminal/command line
20 May 2021, 12:48


Dear Community,

I've been successfully using Visual Studio Code to develop bots and indicators for cTrader. 

However, the building process is at this point non-optimal. I need to switch to cTrader or Visual Studio to compile the project.

What I need is the compilation command so that I can build the MSVC project from the terminal in Visual Studio Code.

I've tried the command dotnet build and some variations of msbuild without success. Sorry, I'm a long-time Linux user and C++ programmer new to .NET projects. 

Best regards,
amml

 

 


@amml
Replies

PanagiotisCharalampous
20 May 2021, 15:33

Hi amml,

Try this cTrader.exe /compile={path_to_csproj}

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous

amml
11 Nov 2021, 10:06 ( Updated at: 11 Nov 2021, 10:09 )

RE:

Hi Panagiotis,

Many thanks for this. It's been a while since you replied and only now I could come back to my algo trading experiments using ctrader. I'm still (apparently) not able to get this right.

I managed to find the path to cTrader.exe via Visual Studio (not sure why, but this was a non-trivial finding, as things in AppData are hidden away from users -- I'm new to Windows):

C:\Users\amml\AppData\Local\Apps\2.0\RW0TM076.FG6\4SEMHSJE.LY5\xtrader_9ah856fd4bdxd746_0002.0002_270472ff031s70h9\cTrader.exe

Let's say the path to MyFirstRobot.csproj is 

C:\Users\amml\Documents\cAlgo\Sources\Robots\MyFirstRobot\MyFirstRobot

In the command prompt, if I execute this:

C:\Users\amml\AppData\Local\Apps\2.0\RW0TM076.FG6\4SEMHSJE.LY5\xtrader_9ah856fd4bdxd746_0002.0002_270472ff031s70h9\cTrader.exe /compile=C:\Users\amml\Documents\cAlgo\Sources\Robots\MyFirstRobot\MyFirstRobot

nothing seems to happen (no algo file built, no output whatsoever). I've also tried adding MyFirstRobot.csproj to the end of the path above, and nothing seems to happen.

Could you please point me to the documentation of this (I could not find docs for cTrader.exe) or tell me what I'm doing wrong? 

Best regards,
amml

 


@amml

PanagiotisCharalampous
11 Nov 2021, 10:10

Hi amml,

This function is not documented at the moment. However it seems that your path does not include the project file name. You should include the file name in the path as well e.g.

C:\Users\amml\Documents\cAlgo\Sources\Robots\MyFirstRobot\MyFirstRobot\MyFirstRobot.csproj

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous

amml
11 Nov 2021, 10:25

RE:

Hi Panagiotis,

I got it working now - many thanks. The output is a MyFirstRobot.algo file under 

C:\Users\amml\Documents\cAlgo\Sources\Robots\

Could you please tell me other command line options besides /compile? I'm particularly interested in a more verbose output (currently, I see no output, so not sure if there are errors).

Best regards,
amml

 


@amml

amml
11 Nov 2021, 10:43

For whoever that wants to use Visual Studio Code and build from there, create a task.json file under the .vscode folder and add the following:

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Build",
            "type": "shell",
            "command": "C:\\Users\\USERNAME\\AppData\\Local\\Apps\\FIND\\YOURSELF\\YOUR\\PATH\\TO\\cTrader.exe",
            "args": [
                "/compile=${workspaceFolder}\\${workspaceFolderBasename}\\${workspaceFolderBasename}.csproj"
            ],
            "problemMatcher": [],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

You can now press Ctrl+Shift+B and build your .algo file.


@amml

amml
11 Nov 2021, 11:51 ( Updated at: 11 Nov 2021, 11:53 )

RE:

Hi Panagiotis,

I would appreciate to know if there are more command-line options to cTrader.exe besides /compile. Maybe there is an option for verbose output (to detect if there were errors).

Many thanks and best regards,
amml


@amml

PanagiotisCharalampous
11 Nov 2021, 12:04

Hi amml,

No there aren't. This method is not actually supported and from the next update (4.2) you will be able to use dotnet build command instead. So you will need to survive with this workaround till then :).

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous

amml
11 Nov 2021, 13:31

RE:

These are actually very good news. Many thanks for your support, Panagiotis.

Best wishes,
amml

 


@amml

ycomp
02 Jan 2022, 14:20

RE:

any idea when 4.2 is coming out?

PanagiotisCharalampous said:

Hi amml,

No there aren't. This method is not actually supported and from the next update (4.2) you will be able to use dotnet build command instead. So you will need to survive with this workaround till then :).

Best Regards,

Panagiotis 

Join us on Telegram

 


@ycomp

ctid4881225
20 Jan 2022, 06:56

RE:

PanagiotisCharalampous said:

Hi amml,

No there aren't. This method is not actually supported and from the next update (4.2) you will be able to use dotnet build command instead. So you will need to survive with this workaround till then :).

Best Regards,

Panagiotis 

Join us on Telegram

Panagiotis,

 

When 4.2 comes out using the new cross-platform .net does this mean I will be able to build cbots to run on a linux server?

I already have a linux vps for my email websites etc and it would make running cbots so much easier if I could run them on a linux server.

 

Anthony


@ctid4881225

PanagiotisCharalampous
20 Jan 2022, 07:49

Hi Anthony,

cBots cannot run autonomously, they need to be executed in a host application. We are working on a cTrader Console application that will allow you to execute cBots on different operating systems but we cannot commit that this will come in 4.2.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook


@PanagiotisCharalampous

ctid4881225
21 Jan 2022, 01:54

RE:

PanagiotisCharalampous said:

Hi Anthony,

cBots cannot run autonomously, they need to be executed in a host application. We are working on a cTrader Console application that will allow you to execute cBots on different operating systems but we cannot commit that this will come in 4.2.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook

Panagiotis,

This sound great can't wait until it is ready.

As for 4.2 do you have a rough timeline on when it will be available as I am setting up a new system trying to work with vscode and having issues trying to find 4.0 retargeting/developer pack to get the 4.0 assemblies to compile with vscode.

Microsoft seems to not provide anything older than 4.5 at the moment.

Anthony


@ctid4881225