Visual Studio Code For IDE

3148
8
10-24-2018 09:34 AM
BrettLawson
New Contributor III

I'm trying to use visual studio code to debug my custom web app builder widget.  I have set up my dev environment out site of the install directory of C:\WebAppBuilderForArcGIS.  Then I use the scaffolding created by esri-appbuilder-js generator to run grunt and copy my files into the appropriate directories in WebAppBuilderForArcGIS.  My question is how can I now use Visual Studio Code to step through and debug my code? If I use the launch config below then the application page doesn't fully load.  The weird thing is that the moment I detach the visual studio code debugger then it finishes loading.

{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"webRoot": "${workspaceFolder}"
}

If I try to attach the Visual studio code to a running instance of the app in Chrome with the launch config below, then my break points are never hit.

{
"type": "chrome",
"request": "attach",
"name": "Attach to Chrome",
"port": 9222,
"webRoot": "${workspaceFolder}"
},
0 Kudos
8 Replies
ElenaRakovich
New Contributor

I am successfully using Visual Studio 2015 to debug my web app builder widgets. I copied the application folder to C:\inetpub\wwwroot. In IIS configured it as an application. In VS opened File --> Open --> Web Site , navigated to the application folder.

Then opened Debug --> Properties --> Start Options, under "Server" selected "Use custom server" and as "Base URL" gave the application URL ( http://machine_name/app_name ). I am able to debug directly from VS and all breakpoints are hitting.

 

 

Hope it helps.

BrettLawson
New Contributor III

I like the idea of this approach, thanks!

0 Kudos
NicolasRoger
Occasional Contributor

Elena,

could you share more detail about what you did? I have the following questions:

First:

I copied the application folder to C:\inetpub\wwwroot.

...

In VS opened File --> Open --> Web Site , navigated to the application folder.

did you copy ...\WebAppBuilderForArcGIS\server\apps\2 or ..\WebAppBuilderForArcGIS?

Then:

In IIS configured it as an application.

Where can we configure IIS?

Then:

Then opened Debug --> Properties --> Start Options, under "Server" selected "Use custom server" and as "Base URL" gave the application URL ( http://machine_name/app_name ).

What debugger did you check under the server "Use custom server". I have the following choices. Am I missing any?:

Thank you

EDIT:

Nevermind I got it. I'll post my solution below.

0 Kudos
NicolasRoger
Occasional Contributor

So I did almost like Elena suggested but I changed a few things.

1-I am using visual studio2017.

2-I didn't copy app folder anywhere particular (EDIT: The folder is on a local drive. This doesn't seems to work otherwise)

3-In visual studio, I opened a website and navigated to something like " ...\WebAppBuilderForArcGIS\server\apps\2"

4-I have no idea what IIS is or how to configure it so I didn't bother.

5-In the "Start Options" properties, I did like Elena suggested (Custom webserver with adress similar to this: "https://MyComputerName:3344/webappbuilder/apps/2/").

6-Again in the "Start Options" properties, I chose Native debugger:

7-I choose chrome as IIS debugger (whatever that mean):

8-To start debugging, I first manually started  "..\WebAppBuilderForArcGIS\startup.bat". I then went back to visual studio and started debugging => Hit points in the code are hit!

I hope this help someone.

SuiHuang
Occasional Contributor II

This, this detail instruction works for me. I used it in VS2019.

shaylavi
Esri Contributor

I used to work like that until I realized how slow my loading time gets when using VSCode.

You should really consider using the built-in dev tools in chrome.. they're extremely powerful! you can manipulate the code on-the-fly before applying it on VSCode for example.. complete debugging support of course with watch, conditional break points, network examining and much more. and above all maximum performace.. just my two cents.

Shay.

Shay
0 Kudos
NicolasRoger
Occasional Contributor

Ok, I managed to also debug my app in visual studio CODE.

-First you need to install the extension "Debugger for chrome" ( https://marketplace.visualstudio.com/items?itemName=msjsdiag.debugger-for-chrome ) for visual studio code.

-Then you need to open a workspace pointing to your app ( ...\WebAppBuilderForArcGIS\server\apps\2\  for exemple)

-Then you go to Debug/Add configuration.  I used the following configuration:

{
            "type""chrome",
            "request""launch",
            "name""Launch webApp",
            "url""https://MycomputerName:3344/webappbuilder/apps/2/",
            "port"3344,
            "webRoot""${workspaceFolder}"
 }

-Make sure "..\WebAppBuilderForArcGIS\startup.bat" is manually launched then start debugging in visual studio CODE => hit points are hit!

SuiHuang
Occasional Contributor II

I installed debugger for chrome and tried, but got the issue in the screenshot.

attempted to launch debugging from VS Code with chrome

Then I tried again by deleting the attribute "port", this time the WAB site could launch, but VS Code indicates that my break point is unbound.

Is it because of the version difference in VSCode, WAB, and the Debugger for Chrome?

Below are my versions.

I am using WAB 2.17

 

0 Kudos