package | 安装命令 | 说明 |
---|---|---|
c# | ext install csharp | 包括语法高亮显示、智能感知、定义、查找所有引用等。调试支持。网络核心(CoreCLR)。 |
快捷键:Ctrl+P ,然后输入:ext install csharp 即可安装
#使用命令提示符(cmd)或者Windows PowerShell
#1、打开项目文件夹
d: && cd d:\projects
#2、创建项目
dotnet new console -n helloworld
(1)打开项目文件夹
(2)必须插件安装 打开资源管理器(Ctrl+Shift+E),然后打开Progrom.cs文件 VS Code检测到缺少两个插件 OmniSharp,.NET Core Debugger 会自动下载安装
安装完成后的完整输出:
Updating C# dependencies...
Platform: win32, x86_64
Downloading package 'OmniSharp (.NET 4.6 / x64)' (15622 KB) .................... Done!
Downloading package '.NET Core Debugger (Windows / x64)' (43510 KB) .................... Done!
Installing package 'OmniSharp (.NET 4.6 / x64)'
Installing package '.NET Core Debugger (Windows / x64)'
Finished
(3)添加编译&调试配置
插件安装完毕之后,VS Code会提示缺少必要的编译&调试配置,是否添加,选择Yes即可
(4)启动调试
快捷键F5直接启动调试即可
通过调试面板(Ctrl+Shift+D)图形化操作也可
调试输出结果:
-------------------------------------------------------------------
You may only use the Microsoft .NET Core Debugger (vsdbg) with
Visual Studio Code, Visual Studio or Visual Studio for Mac software
to help you develop and test your applications.
-------------------------------------------------------------------
Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.0-preview2-25407-01\System.Private.CoreLib.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded 'd:\Projects\helloworld\bin\Debug\netcoreapp2.0\helloworld.dll'. Symbols loaded.
Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.0-preview2-25407-01\System.Runtime.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.0-preview2-25407-01\System.Console.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.0-preview2-25407-01\System.Threading.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.0-preview2-25407-01\System.Runtime.Extensions.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Hello World!
The program '[4180] helloworld.dll' has exited with code 0 (0x0).
毕竟是微软的工具+微软的SDK,结合起来是蛮方便的 比起 .NET Core 1.0 刚出来的时候(毕竟当时VS Code也简陋),少了很多步骤。是真的爽。 .NET Core 搞起来~