Go Down

Topic: Building with Visual Studio Code (on OSX) (Read 1 time) previous topic - next topic

davepl

Sep 27, 2018, 04:57 pm Last Edit: Sep 27, 2018, 04:58 pm by davepl
I don't think the OSX part matters, but I've got Visual Studio Code working, I have the Arduino extensions for it, and I have my .ino workspace loaded.

When I try to build, however, I get "Configure Build Task".  I can't get past that.  I can create a json build task file and so on but ... I'm stuck.  Please tell me the simple baby steps needed, not big things like "Configure the json script that controls the build process", I need to know how to do that.

Most of the tutorials stop with installing the Arduino extensions, which was the easy part.  If someone could tell me the steps or point me at an article on how to :

COMPILE
BUILD
RUN

Those are the three steps that have me totally stymied.  I would appreciate any actionable help (as opposed to the 'it was hard for me it should be hard for you' approach)!

How do I get from "Configure Build Task" to running project?

davepl

Hmm... am I the only person that's tried?  It -looks- like a really nice environment if I can get it working!

davetcc

#2
Sep 30, 2018, 11:56 pm Last Edit: Oct 01, 2018, 01:38 pm by davetcc
Hi I've been using the Microsoft Arduino plugin for VsCode on Mac.

It's gaining ground quickly from what I can see, but documentation is a bit fragmented.

All the Arduino functions are on the command palette which is accessed using CMD-SHIFT-P. Start typing Arduino and you'll see them all there.
 
When loading a sketch into VsCode for the first time, choose "Arduino - initialize" from the command palette. This sets up the .vscode directory for both c++ and arduino. You'll see JSON config in there. Mostly self explanatory. This also sets up the board type and port etc.

To build onto the device after doing initialise, you'll see there are two other entries on the palette, verify and upload along with a serial monitor. Note that the verify/upload uses the standard Arduino toolchain directly, so if it will compile in the regular IDE, it will compile here, regardless of what the intellisense says.

Also, for language completion on custom libraries, you use have to add them to the includes section in the cpp config file. Open '.vscode/c_cpp_properties.json' and you'll see the includePath section.

It's still early days for this tool at the moment, but I've pretty much stopped using anything else now. I think it's already very good.

Long time Arduino user who enjoys DIY audio and AV equipment.

Edgar1

I am not sure is this helps you. I just setup everything in Windows 10 with Visual Studio Community 2017 and it works (so far).

I worked mostly according to these lists:
https://www.visualmicro.com/page/User-Guide.aspx?doc=Getting-started.html
https://www.visualmicro.com/page/User-Guide.aspx?doc=First-steps.html
https://www.visualmicro.com/page/User-Guide.aspx?doc=Test-New-Installation.html

I documented what I did. Here is my list:
Visual Studio Community 2017 was installed
Update to newest version (15.8.8)
Add C++ in VS
Restart PC
In VS: Tools, Extensions and Updates
 Search in Online for Arduino
  Download Arduino IDE for Visual Studio
 Restart VS to install it.
After Restart Window "Configure Ide Locations" comes up
 I press "Download/Install Ide"
  I download: Windows Installer, for Windows XP and up
   arduino-1.8.7-windows.exe
  I install that file in default folder
   C:\Program Files (x86)\Arduino

Remarks for the OP
 The Window "Configure Ide Locations" needs the path to the .exe file.
  In my case C:\Program Files (x86)\Arduino
 I am sure that is important and that might be the missing part in your installation

Test according to list below
 make first project
  error
  buy screen - ignore in the moment
Connect Arduino
Use Arduino standard program to find port
 Close Arduino standard problem (otherwise the port is blocked by that program)
 Set in VS the Arduino type and port
 Copy blink program to VS
  compile ok
  Upload error can't open device
  close, open, try again, check connection, try again, ok

Until now simple projects work.
I still have to figure out a project with a library which uses another library.


davetcc

Hi Edgar,

VS code is a different product to Visual studio. Visual Micro is a great plugin but only available on Windows for Visual Studio.

VS code is cross platform and uses an open source Arduino plugin developed by Microsoft themselves.

It is generally very good - although intelli-sense is still a bit off occasionally. In fact I like it so much I've all but stopped using eclipse and other options.

Dave.
Long time Arduino user who enjoys DIY audio and AV equipment.

davepl

I finally do have everything working - if there was a start and an and to that process I would document it but its really just a lot of dorking around!

I've got everything except OTA updating working at this point!

Like the Dave above, I've actually stopped using eclipse, the arduino ide, or visual micro at this point. 

sstaub

Try PlatformIO https://platformio.org The Microsoft Plugin is not a funny thing and needs very big improvements.

davetcc

Im sure platform io has many advantages. The VS code Arduino plugin is very new.

I'm often developing libraries for many uses. These libraries need example INO files that ship with them. What I really like about VScode is that I just set the library directory as the project, and work with any one of the ino examples very quickly.

What I'm most concerned about is ending up with a library that doesn't work properly in the true Arduino environment. The VScode plugin uses the genuine tool chain.
Long time Arduino user who enjoys DIY audio and AV equipment.

Go Up