2016-03-07 160 views
0

我有使用IIS 10去格式化这样一个位置,我的本地设置一个虚拟目录在Visual Studio代码显示虚拟目录路径...Visual Studio代码 - 而调试

http://vscode.dev/ 

,我可以看到我在我的index.htm页面上按下F5时,调试过程开始。我选择Chrome。然后我看到我在我的Chrome浏览器的网址去这样的事情...

file:///C:/Users/my-name/Documents/Visual%20Studio%202015/VS%20Projects/VSCode/sandbox/index.htm 

这一切都被在Visual Studio代码生成从launch.json网页...

{ 
    "version": "0.2.0", 
    "configurations": [ 
     { 
      "name": "Launch current file", 
      "type": "chrome", 
      "request": "launch", 
      //"file": "${workspaceRoot}/${file}" 
      "file" : "${file}" 
     }, 
     { 
      "name": "Launch localhost with sourcemaps", 
      "type": "chrome", 
      "request": "launch", 
      "url": "http://localhost/mypage.html", 
      "sourceMaps": true, 
      "webRoot": "wwwroot" 
     }, 
     { 
      "name": "Attach", 
      "type": "chrome", 
      "request": "attach", 
      "port": 9222 
     } 
    ] 
} 

所以这里是我的问题....在这个页面中,我可以替换${file}的部分路径,就像我们在JavaScript中使用replace()方法一样吗?像...

${file}.replace{'file:///C:/Users/my-name/Documents/Visual%20Studio%202015/VS%20Projects/VSCode/sandbox/':'http://vscode.dev/'} 

...这种方式每当我调试我的.htm页面,它会去一个更干净的URL路径?像这样的....

http://vscode.dev/index.htm 

如果我走了,并没有实现我的目标更有效的方式,我希望这条道路也是如此。感谢您的任何提示!

回答

0

我想我明白了。就在Visual Studio代码调试之前,我就回成launch.json文件,并替换该文件:有场下的“启动的index.html” ......

"url": "http://vscode.dev/${fileBasename}" 

所以每当我点击F5,我得到的在我的Chrome浏览器下面的路径...

http://vscode.dev/index.htm 

我喜欢这个,就是这个过程是你工作中的每一个Visual Studio代码文件夹独特,和Visual Studio代码会记住推出!

仅供参考 - Visual Studio代码变量替换可以在这里找到 - https://code.visualstudio.com/docs/editor/tasks。另外,在执行此过程时,您可能需要在Windows计算机上侦听可用端口。并将该端口值添加到launch.json文件中。