1# Visual Studio's external build projects
2
3Visual Studio supports developing projects that have an external build
4system. If you wish to use this integration method, here is how you
5set it up. This documentation describes Visual Studio 2019. Other
6versions have not been tested, but they should work roughly in the
7same way.
8
9## Creating and compiling
10
11Check out your entire project in some directory. Then open Visual
12Studio and select `File -> New -> Project` and from the list of
13project types select `Makefile project`. Click `Next`.
14
15Type your project's name In the `Project name` entry box. In this
16example we're going to use `testproj`. Next select the `Location`
17entry and browse to the root of your projet sources. Make sure that
18the checkbox `Place solution and project in the same directory` is
19checked. Click `Create`.
20
21The next dialog page defines build commands, which you should set up
22as follows:
23
24| entry | value |
25| ----- | ----- |
26|build  | `meson compile -C $(Configuration)` |
27|clean  | `meson compile -C $(Configuration) --clean` |
28|rebuild| `meson compile -C $(Configuration) --clean && meson compile -C $(Configuration)` |
29|Output | `$(Configuration)\name_of_your_executable.exe|
30
31
32Then click `Finish`.
33
34Visual Studio has created a subdirectory in your source root. It is
35named after the project name. In this case it would be `testproj`. Now
36you need to set up Meson for building both Debug and Release versions
37in this directory. Open a VS dev tool terminal, go to the source root
38and issue the following commands.
39
40```
41meson testproj\Debug
42meson testproj\Release --buildtype=debugoptimized
43```
44
45Now you should have a working VS solution that compiles and runs both
46in Debug and Release modes.
47
48## Adding sources to the project
49
50This project is not very useful on its own, because it does not list
51any source files. VS does not seem to support adding entire source
52trees at once, so you have to add sources to the solution manually.
53
54In the main view go to `Solution Explorer`, right click on the project
55you just created and select `Add -> Existing Item`, browse to your
56source tree and select all files you want to have in this project. Now
57you can use the editor and debugger as in a normal VS project.
58