首页 技术 正文
技术 2022年11月10日
0 收藏 776 点赞 3,339 浏览 1115 个字

使用VS Code开发 调试.NET Core RC2应用程序,由于.NET Core 目前还处于预览版。

本文使用微软提供的示例进行开发及调试。

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

.NET Core 介绍及说明:

https://github.com/dotnet/cli

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

环境安装

本文开发的实际环境: win10 x64 VSCode 1.0

1:VSCode :

https://code.visualstudio.com/

安装好VSCode以后,打开VSCode 安装C#插件。

2:VSCode C#插件:

Ctrl+P 打开Quick Open 输入: ext install csharp  选择C# 安装

3:.NET Core SDK Installer:

在:https://www.microsoft.com/net/core

找到: .NET Core SDK for Windows  下载安装(也可以直接点击:https://go.microsoft.com/fwlink/?LinkID=827524   下载)

下载(Github-Git服务)(可选

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

 

验证:打开VSCODE

安装好以后 F1 会发现多了dotnet 命令,证明也就安装完成。

使用VS Code开发 调试.NET Core 应用程序

开发调试

下载微软的示例代码:https://github.com/aspnet/cli-samples

下载代码后,使用VSCode 打开文件夹 cli-samples/HelloMvc

使用VS Code开发 调试.NET Core 应用程序

F1 输入 dotnet restore

选择对应的dotnet restor (这里显示好像是插件的bug)

使用VS Code开发 调试.NET Core 应用程序

 

你还可以直接在文件夹打开命令行,输入 dotnet restore 同样可以还原相关引用。

还原好相关的引用以后我们就可以进行调试了。

点击调试 程序就跑起来。

使用VS Code开发 调试.NET Core 应用程序

使用VS Code开发 调试.NET Core 应用程序

这样就可以下断点调试。

访问 http://localhost:5000/

使用VS Code开发 调试.NET Core 应用程序

开发

我们来添加一个新的Action

使用VS Code开发 调试.NET Core 应用程序

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

使用VS Code开发 调试.NET Core 应用程序

访问: http://localhost:5000/about

使用VS Code开发 调试.NET Core 应用程序

下断点调试一下程序,断点设置跟VS一样。

使用VS Code开发 调试.NET Core 应用程序

断下来以后,可以查看对应的属性以及值。

左侧有对应的监视器,可以查看各个值。

这样我们已经可以调试.NET Core。

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,492
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,907
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,740
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,493
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,132
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,295