2016-05-05 59 views
1

我正在同时处理多个项目,其中一个我想使用Chrome Canary在Visual Studio代码中调试我的应用程序。如何配置Visual Studio代码调试器以使用Chrome Canary?

因此对于稳定铬我有

{ 
     "name": "Launch Chrome", 
     "type": "chrome", 
     "request": "launch", 
     "url": "http://localhost:7246/", 
     "runtimeArgs": [ 
      "--new-window", 
      "--remote-debugging-port=9222" 
     ], 
     "webRoot": "${workspaceRoot}/app/" 
} 

有没有什么简单的方法launch.json配置到一个单独的调试端口(9223为例)上使用Chrome Canary版,这样我就可以使用铬稳定与调试端口9222所有其他的东西?

回答

3

您应该可以使用runtimeExecutable属性指定要测试的Chrome版本的路径,并结合runtimeArgs指定该配置的不同调试端口。 launch.json中的configurations属性允许您指定一组配置。

我没有看过VS代码自己,所以无法验证这一点,但这里是一些有用的信息:https://github.com/Microsoft/vscode-chrome-debug

更新 您可以使用一个环境变量路径,而不是绝对路径。

在命令提示符下,尝试这样的事情创建环境变量:

set CHROME_PATH=C:/Users/[USER]/AppData/Local/Google/Chrome SxS/Application 

在config文件中,路径可以这样引用:

${env.CHROME_PATH}/chrome.exe 

退房https://code.visualstudio.com/Docs/editor/tasks#_variable-substitution更多细节。

+0

的感谢!你知道你是否可以以某种方式在配置路径中使用系统环境变量? – raduf

+0

在发现可以使用变量替换后,我添加了对我的解决方案的更新。我希望这有帮助。 –

+0

非常感谢你!真正有用的东西 – raduf

4

对我来说Chrome Canary版的工作版本是

{ 
     "name": "Chrome Canary", 
     "type": "chrome", 
     "request": "launch", 
     "url": "http://localhost:7246/", 
     "port": 9223, 
     "runtimeExecutable": "${env.USERPROFILE}/AppData/Local/Google/Chrome SxS/Application/chrome.exe", 
     "runtimeArgs": [ 
      "--new-window", 
      "--remote-debugging-port=9223" 
     ], 
     "webRoot": "${workspaceRoot}/app/" 
} 
相关问题