31st October 2024
A CLI tool is free and can be used with projects created or edited with Visual Micro : Download VMBuilder.zip
The tool can compile standard arduino projects or visual studio projects.
- minimal syntax example:-
- "[some_path]\vmbuilder.exe" -builder.project_path="[project path and name].vcxproj" -builder.build=true
- with logging example. log file will be in the \bin folder below the vmbuild.exe:-
- "[some_path]\vmbuilder.exe" -builder.project_path="[project path and name].vcxproj" -builder.build=true [b]-builder.verbose=true -builder.log=true -builder.dump_props=true -builder.close=true
Note: Windows 11 often opens the powershell tool instead of cmd.exe. Use:- cmd.exe OR a .bat file OR to run an exe via powershell, prefix the command with cmd.exe /c
When compilng a folder or .ino name, only the standard arduino project folder and project\src... folder structure is compiled.
When comping a visual studio project the project governs the files to be compiled (as expected for visual micro). Shared linked external source code, shared code projects and shared library projects are all supported (as normal).
All paramaters can optionally be enclosed with double quotes (speech marks). Paths that contain spaces and other special characters must be enclosed with double quotes!
Examples:
1. Build and upload a visual studio (visual micro) project. Uses the first board that has a name or id containing the text "2560". Upload using serial port COM3 (verbose enabled)
VMBuild.exe -builder.verbose=true -builder.build=true -builder.upload=true -builder.board_id=2560 -builder.project_path="C:\Users\Test\Documents\Arduino\ArduinoProject\ArduinoProject.vcxproj" -builder.serial_port=COM3
2. Build and upload a simple arduino project via the master .ino name. Uses the first board that has a name or id containing the text "Uno". Upload using serial port COM3
VMBuild.exe -builder.build=true -builder.upload=true -builder.board_id=Uno -builder.project_path="C:\Users\Test\Documents\Arduino\ArduinoProject1\ArduinoProject1.ino" -builder.serial_port=COM3
3. Build and upload a simple arduino project via the folder name. Uses the first board that has a name or id containing the text "Uno". Upload using serial port COM3
VMBuild.exe -builder.build=true -builder.upload=true -builder.board_id=Uno -builder.project_path="C:\Users\Test\Documents\Arduino\ArduinoProject\ArduinoProject.vcxproj" -builder.serial_port=COM3
4. Clean the temp build cache for the given project and the Uno board
VMBuild.exe -builder.clean=true -builder.board_id=Uno -builder.project_path="C:\Users\Test\Documents\ArduinoProject\ArduinoProject.vcxproj" -builder.serial_port=COM3
5. Burn a bootloader using the specified programmer
VMBuild.exe -builder.board_id=Uno -builder.project_path="C:\Users\Test\Documents\Arduino\ArduinoProject" -builder.burn_bootloaderx=true -builder.programmer=avrispmkii
6. Copy final output files to specified directory.
VMBuild.exe -builder.output_directory="c:\test\output\sketch" -builder.clean=true -builder.board_id=Uno -builder.project_path="C:\Users\Test\Documents\Arduino\ArduinoProject\ArduinoProject.ino" -builder.serial_port=COM3
7. Print a list of boards for the currently selected ide/configuration
VMBuilder.exe -builder.dump_boards=false
8. Build and upload a visual studio (visual micro) project. Uses the first board that has a name or id containing the test "2560". Upload using programmer
VMBuild.exe -builder.build=true -builder.upload=true -builder.board_id=2560 -builder.project_path="C:\Users\Test\Documents\Arduino\ArduinoProject\ArduinoProject.vcxprojj" -builder.programmer=avrispmkii
9. Override the Arduino IDE location on-the-fly
VMBuild.exe -builder.ide_path="D:\Arduino\arduino-1.8.1" -builder.build=true -builder.upload=true -builder.board_id=2560 -builder.project_path="C:\Users\Test\Documents\Arduino\ArduinoProject\ArduinoProject.vcxproj" -builder.programmer=avrispmkii
10. Export and combine all code into a sketch zip
VMBuild.exe -builder.project_path="D:\MySystem\Documents\Arduino\Test\Test.vcxproj" -builder.export_sketch=true -builder.export_delete_if_exists=true -builder.export_dest_file="D:\MySystem\Documents\Arduino\Test\Test.zip"
nb: if builder.export_dest_file is not provided export will be to a unique file name in folder "project\__vm\export"
.........
VmBuild supports the following switches along with the ability to override any of the standard build settings:-
All settings are optional apart from project_path (or ino_path). Using the .vcxproj path is recommended. Using ino_path does not provide project settings or shared project code in the build.
- -builder.project_path="C:\Users\Test\Documents\Arduino\MySolution\MyProject\MyProject.vcxproj"
- -builder.portable_path=[Path to an arduino portable folder] recommended to set it to "MySolution\arduino-portable" so that the solution/project in the ide also uses it. It can be any location that is a copy of the standard arduino "users\[name]\appData\local\Arduino15" folder. Rules are the same as "Arduino Portable"
- -builder.board_id=2560
- -builder.build=true
- -builder.rebuild=false
- -builder.upload=true
- -builder.clean=false
- -builder.parallel_build=false
- -builder.application_id=visualmicro
- -builder.application_id=arduino20x
- -builder.application_id=arduino16x
- -builder.ide_path="D:\Arduino\arduino-1.8.12"
- -builder.verbose=true
- -builder.verbose_warnings=true
- -builder.log=true
- -builder.dump_props=false
- -builder.dump_boards=false
- -builder.output_directory="c:\test\output\sketch"
- -builder.dump_source_list=true
- -builder.serial_port=COM3
- -builder.burn_bootloaderx=true
- -builder.programmerx=avrispmkii
- -builder.close=true (default is false)
- -builder.closeonerror=true (default is false)
- -builder.configuration=Release (relevent only if board and port are saved per project configuration)
- -builder.export_sketch=true
- -builder.export_delete_if_exists=true (optional)
- -builder.export_dest_file=file name and path (optional)
- -builder.build_temp_path=Path where compiler will build the project. IMPORTANT: Should NOT point to the project or a folder that can not be deleted at any time.
- -builder.packages_path=Path to the board packages folder. By default it is "appdata\arduino15" but also can be overriden via "arduino-cli.yaml>dir.data" or "vMicro>general options>contributions folder"
- -builder.args_file=[path to these build settings]. A file containing a property on each line without the dash prefix
There is also a video showing the CLI below: