最新教程:http://www.cnblogs.com/linezero/p/VSCodeASPNETCore.html
使用VS Code開發ASP.NET Core 應用程序
准備
1.安裝VS Code https://code.visualstudio.com/
2.安裝Node.js https://nodejs.org/
安裝 ASP.NET Core and DNX
首先安裝DNVM
CMD
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "&{$Branch='dev';$wc=New-Object System.Net.WebClient;$wc.Proxy=[System.Net.WebRequest]::DefaultWebProxy;$wc.Proxy.Credentials=[System.Net.CredentialCache]::DefaultNetworkCredentials;Invoke-Expression ($wc.DownloadString('https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.ps1'))}"
Powershell
&{$Branch='dev';$wc=New-Object System.Net.WebClient;$wc.Proxy=[System.Net.WebRequest]::DefaultWebProxy;$wc.Proxy.Credentials=[System.Net.CredentialCache]::DefaultNetworkCredentials;Invoke-Expression ($wc.DownloadString('https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.ps1'))}
二者選一即可。
安裝好以后就可以使用dnvm 命令。
在cmd 輸入
where dnvm
就會顯示dnvm 的安裝路徑。
安裝生成ASP.NET Core應用程序工具
在cmd 輸入
npm install -g yo generator-aspnet gulp bower
如果沒有npm 請先安裝npm 環境。
安裝好 yo 以后,我們就可以使用 yo 生成 ASP.NET Core 應用程序。
在cmd 輸入
yo aspnet
我們選擇Web Application,然后輸入名稱,很快就生成好了程序。
使用VS Code 打開文件夾。
然后F1 打開VS Code 命令行,輸入 dnx: Restore Packages 回車。
還原好以后,我們就再F1 打開VS Code 命令行,輸入 dnx: Run Command 回車。
然后選擇dnx web ,出現如下界面,成功運行。
在瀏覽器地址欄輸入: http://localhost:5000/
VS Code 暫時無法調試ASP.NET Core,期待正式版可以進行調試開發。
VS Code 編寫代碼還是沒有問題的,智能提示都是很完全。
參考文檔:
https://code.visualstudio.com/docs/runtimes/ASPnet5
如果你覺得本文對你有幫助,請點擊“推薦”,謝謝。