Skip to content

How To Compile the MT API .NET project

eabase edited this page Nov 13, 2020 · 1 revision

How To Compile the MT API .NET project

🥵 ➡️ 🥇

Here are the instructions to compile this whole project for MT4 on a Win8.1 & VS 2017.
A copy of these are better maintained in the COMPILE.md file of the mtapi project.


First things first. make sure you have cloned the latest version of this repo.

  • Note: ❗
    Here I use a shallow clone, because I am not yet interested in making dev changes, just build the project.
    If you need to do dev and make PR's, you have to use a normal/full clone.
# cd D:\myDev\_gh_cloned\
#git clone --depth=1 --no-tags [email protected]:vdemydiuk/mtapi.git 	# ssh -- better
git clone --depth=1 --no-tags https://github.com/vdemydiuk/mtapi.git 	# http --faster
cd mtapi

Requirements & Installation Instructions

Next Prepare yourself for Visual Studio 2019 (from now on just "VS"). (But here I use 2017.) You need to install a bunch, and I mean a lot of, yes too many, dependencies. Otherwise you will run into all sorts of weird stuff. So if you're new to VS, just make sure you have the latest updated version.

Click for a Surprise!

devenv_2020-11-13_20-39-14


  • Install Visual Studio 2019 from here.
  • Install the WIX stuff from above ...
  • Install the 2 .NET Framework's: .NET 4.8, .NET 4.7.2 and .NET Core (5.0) from here:
Click Me!

firefox_2020-11-13_20-31-59

firefox_2020-11-13_20-33-10

  • Fire up the Visual Studio Installer and install the following items:
Click Me!

vs_installershell_2020-11-13_21-02-48

vs_installershell_2020-11-13_19-39-17

  • Also make sure you install the C++/CLI package.

More interestingly you may also try to just import all the requirements I had, by clicking "Import Configuration" in the drop-down (as shown in the screenshot below). Save the following text/code into a file called .vsconf and import it.

Click Me!

vs_installershell_2020-11-13_21-56-43

➡️ Import This:

{
	"version": "1.0",
	"components": [
		"Microsoft.VisualStudio.Workload.ManagedDesktop",
		"Microsoft.VisualStudio.Workload.NativeDesktop",
		"microsoft.net.componentgroup.targetingpacks.common",
		"microsoft.componentgroup.blend",
		"microsoft.visualstudio.component.entityframework",
		"microsoft.visualstudio.component.diagnostictools",
		"microsoft.visualstudio.component.debugger.justintime",
		"microsoft.net.componentgroup.4.7.2.developertools",
		"microsoft.visualstudio.component.vc.diagnostictools",
		"microsoft.visualstudio.component.vc.cmake.project",
		"microsoft.visualstudio.component.vc.atl",
		"microsoft.visualstudio.component.vc.testadapterforboosttest",
		"microsoft.visualstudio.component.vc.testadapterforgoogletest",
		"microsoft.visualstudio.componentgroup.nativedesktop.win81",
		"microsoft.visualstudio.component.vc.cli.support",
		"microsoft.component.netfx.native",
		"microsoft.visualstudio.component.windows10sdk",
		"component.wixtoolset.visualstudioextension.dev15",
		"component.wixtoolset.visualstudioextension.schemas3",
		"component.wixtoolset.visualstudioextension.schemas4"
	]
}
  • Fire up Visual Studio and open the cloned project repo (mtapi), by clicking:
  1. [File] > Open > Project/Solution (or just type CTRL-SHIFT-o)
  2. Navigate to the path of your repo. For example: D:\myDev\_gh_cloned\mtapi\
  3. Select the solution file, named: MetaTraderApi_2017.sln.
    (Note that VS projects are also called solutions and have the file extension *.sln.)
Click Me!

devenv_2020-11-13_17-57-15

  • Now the project is imported, you need to adjust a few things:
  1. Retarget the project to use Win8.1 instead of Win10, if needed.
  2. Change to use 32-bit builds (for MT4) by default, as shown on top bar of VS.
  3. Select a Startup Project. Set to use: TestApiClientUI, also shown on top bar of VS.
  4. Select what to build in the Configuration Manager....
Click Me!

devenv_2020-11-13_21-22-19

devenv_2020-11-13_21-24-54

devenv_2020-11-13_19-47-57

devenv_2020-11-13_20-11-15

  • You are now ready to Build the project!
    Select: Solution 'MetaTraderApi_2017' (13 projects) and hit F6 or click the Build Solution button.
Click Me!

devenv_2020-11-13_21-33-38

🥇 DONE! 💖