Visual Studio确实是相当好用,各种简化操作什么的简直不要太舒服。但其容量太大,有时不是很方便,所以今天简单介绍一下另一个工具--Visual Studio Code.

虽然相比于老大哥Visual Studio,VS Code有很多功能不完善,但它也更灵活轻便。并且VS Code还在不断的更新当中,目前的最新版本是18年11月更新的1.30版本,包含了 多行搜索改进 等内容。

下面以.Net开发为例:

不同于Visual Studio,在VS Code上进行.Net开发你需要安装一些插件,点击左侧边栏箭头这个位置搜索

安装插件 C# (C# for Visual Studio Code (powered by OmniSharp)) (必须)

    Lightweight development tools for .NET Core.
    1. Great C# editing support, including Syntax Highlighting, IntelliSense, Go to Definition, Find
    All References, etc.
    Debugging support for .NET Core (CoreCLR). NOTE: Mono debugging is not supported. Desktop CLR debugging has limited support.
    Support for project.json and csproj projects on Windows, macOS and Linux.

安装插件 NuGet Package Manager (推荐,方便搜索,安装Nuget包) (推荐)

    Search the NuGet package repository for packages using either (partial or full) package name or another search term.
    Add PackageReference dependencies to your .NET Core 1.1+ .csproj or .fsproj files from Visual Studio Code's Command Palette.
    Remove installed packages from your project's .csproj or .fsproj files via Visual Studio Code's Command Palette.
    Handles workspaces with multiple .csproj or .fsproj files as well as workspaces with single .csproj/.fsproj files.
      1. For example:
    1. Ctrl + P Then Shift + > Choose "Nuget Package Manager: Add Package". Then Input the keyword about the Nuget Package. Finally, Choose the project you want to add the Nuget package.

VSCode 安装插件后一般需要重新激活以启用插件。由于VSCode本身不断更新,对于某些版本的VSCode可能需要重启应用,才能激活插件。
在VSCode中运行调试前,需要在.vscode路径下额外配置两个文件 launch.json tasks.json, 来告诉vscode如何启动项目。
Launch.json:

{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceRoot}/MyABP.Web/bin/Debug/netcoreapp2.1/MyABP.Web.dll",
"args": [],
"cwd": "${workspaceRoot}/MyABP.Web",
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart",
"launchBrowser": {
"enabled": true,
"args": "${auto-detect-url}",
"windows": {
"command": "cmd.exe",
"args": "/C start ${auto-detect-url}"
},
"osx": {
"command": "open"
},
"linux": {
"command": "xdg-open"
}
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceRoot}/Views"
}
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
}

如果你第一次运行某个项目,你需要确保所有引用的内容都存在,如上面的MyAbp.Web.dll文件.另外,这些配置不是固定不变的,你可以根据你的需要来进行不同的配置。

如上面

"preLaunchTask": "build" 指定了你的项目在launch之前要先进行build操作。

又如
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
指定了你要在“哪个环境”下启动你的项目。(实际上一个项目会有多种环境的配置,举个例子 appsetings.Development.json 和 appseting.QA.json用于区分不同环境的配置,如果发现在QA环境出现了问题本地不能重现时,自然需要切换到目标环境来进行调试)

Tasks.json:

{
"version": "0.1.0",
"command": "dotnet",
"isShellCommand": true,
"args": [],
"tasks": [
{
"taskName": "build",
"args": [
"${workspaceRoot}/MyABP.Web/MyABP.Web.csproj"
],
"isBuildCommand": true,
"problemMatcher": "$msCompile"
}
]
}

这里可以配置一下Task,如上面的

"preLaunchTask": "build" 具体的任务流程即在这里配置。

这里除去笔者使用的Web项目的配置外,当然还可以有多种其他项目应用的配置,如

这些配置完成之后,点击如图所示这个位置进入调试面板,然后点击上面的绿色三角就可以开始你的调试啦

/ **************************************************分割线*************************************************************/

vscode下常用DotNet命令
dotnet所使用的命令都可以使用 --help的方式来查看更详细的用法。
如dotnet --help
在项目开发过程中,常用的命令有

dotnet new
用于新建内容,dotnet提供了许多模板,如Console Application, Class Library等等。
使用dotnet new时需要注意新建的项目是基于.Net Framework还是基于.NetCore.
可以使用 -f 来指定.

dotnet restore

主要是寻找当前目录下的项目文件(project.json),然后利用NuGet库还原整个项目的依赖库,然后遍历每个目录,生成项目文件,继续还原该项目文件中的依赖项 --CSDN yangzhenping

以下命令不解释了,可以使用 --help 查看具体用法

dotnet build
dotnet run
dotnet publish

visual studio code .net 开发的更多相关文章

  1. Visual Studio Code 远程开发探秘

    摘要: IDE新时代! 作者:SHUHARI 的博客 原文:Visual Studio Code 远程开发探秘 Fundebug按照原文要求转载,版权归原作者所有. 在以前的文章 有趣的项目 - 在浏 ...

  2. 在Visual Studio Code中开发Office Add-in

    作者:陈希章 发表于 2017年7月13日 上一篇 我介绍了如何在Visual Studio中开发Office Add-in,因为有标准的项目模板,一系列配套的工具,尤其是自带的一键调试功能,可以让开 ...

  3. Visual Studio Code IDE开发插件配置

    [PHP通用集成环境] PHP Extension Pack #PHP拓展包,PHP开发最重要的拓展 PHP Intelephense #PHP自动补全工具 PHP IntelliSense #PHP ...

  4. 使用Visual Studio Code开发AngularJS应用

    (此文章同时发表在本人微信公众号"dotNET每日精华文章",欢迎右边二维码来关注.) 题记:VSC发布之后,尤其最近刚刚更新到0.3之后,社区出现了很多介绍VSC使用的好文章.比 ...

  5. [Tool] 使用Visual Studio Code开发TypeScript

    [Tool] 使用Visual Studio Code开发TypeScript 注意 依照本篇操作步骤实作,就可以在「Windows」.「OS X」操作系统上,使用Visual Studio Code ...

  6. Visual Studio Code开发TypeScript

    [Tool] 使用Visual Studio Code开发TypeScript   [Tool] 使用Visual Studio Code开发TypeScript 注意 依照本篇操作步骤实作,就可以在 ...

  7. 使用Visual Studio Code开发Asp.Net Core WebApi学习笔记(十)-- 发布(Windows)

    本篇将在这个系列演示的例子上继续记录Asp.Net Core在Windows上发布的过程. Asp.Net Core在Windows上可以采用两种运行方式.一种是自托管运行,另一种是发布到IIS托管运 ...

  8. Rust初步(二):使用Visual Studio Code编写Rust程序(猜猜看游戏)

    我是照着下面这篇帮助文档,完成了第一个完整的Rust程序: 猜猜看 游戏 http://kaisery.gitbooks.io/rust-book-chinese/content/content/3. ...

  9. Java on Visual Studio Code的更新 – 2021年8月

    Nick Senior Program Manager, Developer Division at Microsoft 大家好,欢迎来到 8 月版的 Visual Studio Code Java ...

随机推荐

  1. SSM博客登录注册

    我的博客采用的是 spring+springmvc+mybatis框架,用maven和git管理项目,之后的其他功能还有待进一步的学习. 首先新建一个maven项目,我的项目组成大概就这样, 建立好项 ...

  2. Flask入门之Virtualvenv的安装及使用(windows)

    Virtualvenv 提供一个特定的Python虚拟环境(沙盒),以便于那些要求特定版本的模块的脚本能够顺利运行. 因为在Virtualvenv中,我们可以使用 pip install -r req ...

  3. 并发库应用之十一 & 阻塞队列的应用

    队列包含固定长度的队列和不固定长度的队列,队列的规则就是:先进先出.固定长度的队列往里放数据,如果放满了还要放,阻塞式队列就会等待,直到有数据取出,空出位置后才继续放:非阻塞式队列不能等待就只能报错了 ...

  4. IntelliJ IDEA中 todo的使用

    在代码的注释部分加入TODO 大小写忽略,如下图所示 查看项目中有哪些待办项,所下图所示

  5. Jacob工具类使用文件互转服务 word转html html转excel word转pdf excel转pdf ppt转pdf

    前提条件  必须安装MS office 1.jdk使用jdk1.8 2.jacob.dll放在..\jdk1.8\jre\bin目录下 3.eclipse的jre版本要和jdk一致,window-&g ...

  6. python 信息收集器和CMS识别脚本

    前言: 信息收集是渗透测试重要的一部分 这次我总结了前几次写的经验,将其 进化了一下 正文: 信息收集脚本的功能: 1.端口扫描 2.子域名挖掘 3.DNS查询 4.whois查询 5.旁站查询 CM ...

  7. Spring mvc 原理浅析

    2.2. 数据的绑定 前面说过了,SpringMVC是方法级的映射,那么Spring是如何处理方法签名的,又是如何将表单数据绑定到方法参数中的?下面我们就来讨论这个问题.2.2.1. 处理方法签名 首 ...

  8. Node.js 专题

    前提电脑中已经安装过NodeJS, npm.现在需要进行升级操作.1.查看当前的npm和NodeJs的版本: C:\Users\Administrator>node -v v4.4.3 C:\U ...

  9. 阿里云部署java项目参考如下链接

    http://www.cnblogs.com/softidea/p/5271746.html https://oneinstack.com/question/how-to-deploy-java-ap ...

  10. anguments

    anguments是一个对象,长得很像数组的对象,但不是数组,而是伪数组. arguments的内容是函数运行时的实参列表 (function(d, e, f) { console.log(argum ...