[英]Why is wsl (windows subsystem for linux) not available in command prompt when prompt started from the Visual Studio 2019 IDE?
[英]Connecting to the Windows Subsystem for Linux from Visual Studio 2017
我希望從VS2017調試Linux C ++控制台應用程序,如以下教程:
使用適用於Linux的Windows子系統從Visual Studio編寫和調試Linux C應用程序
我已經在我的WSL Ubuntu 16.04安裝中安裝了gdbserver和openssh-server,並且sshd
正在運行,但我無法從VS2017連接。 當我嘗試時,我收到錯誤'Connectivity Failure. Please make sure the host name and port number are correct'
'Connectivity Failure. Please make sure the host name and port number are correct'
。
就我而言,主機名和端口號都是正確的。 我知道WSL仍然是Beta,所以我假設問題與WSL有關(我最近安裝了Windows 10 Creators Update,所以它至少是最新的,但我期待ssh
與CU一起工作)。 我正在使用Windows 10版本1703,Build 15063.250。
更新我讓Visual Studio連接到我的Ubuntu VM,證明它可以工作,問題必須在Windows上使用Bash。 傳入連接沒有任何作用,但傳出連接按預期工作。
有沒有其他人以這種方式從Visual Studio 2017連接到WSL有問題?
使用16299的Windows構建遇到了同樣的問題,現在我可以解決這個問題了。 發布決議,以防它幫助任何其他程序員。 (雖然詹姆斯可能已經解決了它)
默認情況下,WSL缺少開放的ssh服務器。 必須首先配置它才能與Visual Studio連接
要仔細檢查一下。 轉到Powershell並運行netstat -an。 我無法在localhost :: 22上找到任何運行的東西。
按照以下說明在WSL安裝上安裝open ssh並運行open ssh server。
在nestat -an的輸出中,現在您應該看到類似下面的內容
Proto Local Address Foreign Address State
TCP 0.0.0.0:22 0.0.0.0:0 LISTENING
現在,我能夠將VS連接到WSL。 :-)干杯!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.