使用VS Code開發 調試.NET Core 應用程序

最新文章:http://www.cnblogs.com/linezero/p/VSCodeNETCore.html

使用VS Code開發 調試.NET Core RC2應用程序,因爲.NET Core 目前還處於預覽版。html

本文使用微軟提供的示例進行開發及調試。git

https://github.com/aspnet/cli-samplesgithub

.NET Core 介紹及說明:windows

https://github.com/dotnet/clispa

http://dotnet.github.io/getting-started/.net

環境安裝

本文開發的實際環境: win10 x64 VSCode 1.0插件

下載命令行

https://github.com/dotnet/cli#installers-and-binaries3d

.NET Core SDK Installer:調試

https://dotnetcli.blob.core.windows.net/dotnet/beta/Installers/Latest/dotnet-dev-win-x64.latest.exe

VSCode :

https://code.visualstudio.com/

VSCode C#插件:

https://github.com/OmniSharp/omnisharp-vscode/releases

最新版: https://github.com/OmniSharp/omnisharp-vscode/releases/download/v1.0.4-rc2/csharp-1.0.4-rc2.vsix

安裝好VSCode之後,打開VSCode 安裝C#插件。

安裝插件:直接用VSCode 打開插件文件就能夠安裝了。

安裝好之後 F1 會發現多了dotnet 命令,證實也就安裝完成。

開發調試

下載微軟的示例代碼:https://github.com/aspnet/cli-samples

下載代碼後,使用VSCode 打開文件夾 cli-samples/HelloMvc

F1 輸入 dotnet restore

選擇對應的dotnet restor (這裏顯示好像是插件的bug)

 

你還能夠直接在文件夾打開命令行,輸入 dotnet restore 一樣能夠還原相關引用。

還原好相關的引用之後咱們就能夠進行調試了。

點擊調試 程序就跑起來。

 

這樣就能夠下斷點調試。

訪問 http://localhost:5000/

 

開發

咱們來添加一個新的Action

        [HttpGet("/about")]
        public IActionResult About(){
            var useragent=Request.Headers["User-Agent"];
            return Content(useragent+"\r\nabout by linezero");
        }

訪問: http://localhost:5000/about

下斷點調試一下程序,斷點設置跟VS同樣。

斷下來之後,能夠查看對應的屬性以及值。

左側有對應的監視器,能夠查看各個值。

這樣咱們已經能夠調試.NET Core。

 

若是你以爲本文對你有幫助,請點擊「推薦」,謝謝。

相關文章
相關標籤/搜索