2016-03-07 170 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文件中。