You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
title: Build an ASP.NET Core app on a Mac or Linux using Visual Studio Code | Microsoft Docs
2
+
title: 用 Visual Studio Code 在 macOS 或 Linux 上创建首个 ASP.NET Core 应用程序 | Microsoft Docs
3
3
author: spboyer
4
4
description: This article will walk you through creating your first web application on a Mac using the dotnet CLI for ASP.NET Core and Visual Studio Code
5
5
keywords: ASP.NET Core, macOS, Yeoman, generator-aspnet, Visual Studio Code, Linux, VS Code
@@ -12,26 +12,30 @@ ms.technology: aspnet
12
12
ms.prod: asp.net-core
13
13
uid: tutorials/your-first-mac-aspnet
14
14
---
15
-
# Build an ASP.NET Core app on a Mac or Linux using Visual Studio Code
15
+
# 用 Visual Studio Code 在 macOS 或 Linux 上创建首个 ASP.NET Core 应用程序
16
16
17
-
This article will show you how to write your first ASP.NET Core application on macOS or Linux.
Download and install [.NET Core](https://microsoft.com/net/core) and [Visual Studio Code](https://code.visualstudio.com) with the [C# extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.csharp).
21
+
## 配置开发环境
22
22
23
-
## Scaffolding applications using dotnet new
23
+
下载并安装 [.NET Core](https://microsoft.com/net/core) 和 [Visual Studio Code](https://code.visualstudio.com),以及 [C# 扩展](https://marketplace.visualstudio.com/items?itemName=ms-vscode.csharp)。
24
24
25
-
We will be using `dotnet new` to generate a new web application using the "Empty Web Template". Create a working directory for your project called *firstapp* . cd to *firstapp*.
25
+
## 使用 dotnet new 的脚手架来新建应用
26
+
27
+
我们使用 `dotnet new` 并使用「Empty Web Template」创建新应用程序。为项目创建一个工作目录,取名为 *firstapp*,并用 `cd` 命令进入该文件夹。
28
+
29
+
启动 Visual Studio Code,打开 *firstapp* 文件夹。点击 Ctrl + '\`'(反引号)来打开 VS Code 内集成的终端。当然也可以选择使用单独的终端窗口。
30
+
31
+
运行 `dotnet new` 命令创建 Web 应用程序,传递 `mvc` 参数作为模板类型。
26
32
27
-
Start Visual Studio Code and open the *firstapp* folder. Press Ctrl + '\`' (the back-quote character) to open an embedded terminal in VS Code. Alternatively, use a separate terminal window.
28
-
Run the `dotnet new` command to create a new web application, passing the `mvc` parameter as the template type.
29
33
30
34
```console
31
35
dotnet new mvc
32
36
```
33
37
34
-
If you get an error running `dotnet new mvc`, install the latest [.NET Core](https://microsoft.com/net/core). When the CLI command completes; the following output and files are produced.
38
+
如果在运行 `dotnet new mvc` 时出现错误,安装最新版的 [.NET Core](https://microsoft.com/net/core)。当 CLI 命令完成,会生成下列输出和文件。
35
39
36
40
```console
37
41
Content generation time: 79.6691 ms
@@ -43,117 +47,117 @@ The template "Empty ASP.NET Core Web Application" created successfully.
## Developing ASP.NET Core applications on a Mac and Linux with Visual Studio Code
50
+
## 在 macOS 和 Linux 上使用 Visual Studio Code 开发 ASP.NET 应用程序
47
51
48
-
Open the project folder in Visual Studio Code (VS Code) and select the *Startup.cs*file.. VS Code will prompt to restore the needed project dependencies and add build/debug dependencies. Tap **Yes**to add the build and debug assets and then tap **Restore**to restore the project dependencies.
52
+
在 Visual Studio Code(VS Code)打开项目文件夹,然后选择 *Startup.cs*文件。VS Code 将立即还原(restore)项目所需的依赖项,并添加生成/调试依赖项。点击 **Yes**添加生成和调试资源,然后点击 **Restore**来还原项目依赖。
49
53
50
54

51
55
52
-
For **Restore**, alternately, you can run `dotnet restore`from the terminal or enter `⌘⇧P`or`Ctrl+Shift+P` in VS Code and then type `.NET` as shown:
56
+
**Restore** 时,可以在终端运行 `dotnet restore`或是在 VS Code 中输入 `⌘⇧P`或`Ctrl+Shift+P`,然后键入 `.NET`,如下所示:
53
57
54
58

55
59
56
-
VS Code provides a streamlined, clean interface for working with files and a productive coding enviromment.
60
+
VS Code 为工作文件和生产代码环境提供了流畅简洁的界面。
57
61
58
-
In the left navigation bar, there are five icons, representing four viewlets:
62
+
左侧导航栏中的四个图标分别代表五种功能:
59
63
60
-
*Explore
61
-
*Search
64
+
*资源管理器
65
+
*搜索
62
66
* Git
63
-
*Debug
64
-
*Extensions
67
+
*调试
68
+
*扩展
65
69
66
-
The Explorer viewlet provides folder navigation and a view of the files you have open. It displays a badge to indicate files with unsaved changes. You can create new folders and files in the viewlet. You can select **Save All** from a menu option that appears on mouse over.
The Search viewlet allows you to search the folder tree of files you have open. The search is for filenames and file contents.
72
+
搜索视图允许在已开文件的目录树下搜索文件名及内容。
69
73
70
-
*VS Code*will integrate with Git if it is installed on your system. You can initialize a new repository, make commits, and push changes from the Git viewlet.

73
77
74
-
The Debug viewlet supports interactive debugging of applications.
78
+
调试视图支持为应用程序进行交互式调试。
75
79
76
-
VS Code's editor has a ton of great features. You'll notice unused using statements are underlined and can be removed automatically by using `⌘ .`or`Ctrl + .`when the lightbulb icon appears. Classes and methods also display how many references there are in the project to them.
80
+
VS Code 的编辑器还提供了一些非常出色的特性,比如你会注意到未使用的 using 语句会带有下划线,当出现电灯图标时可使用 `⌘ .`或`Ctrl + .`自动移除之。类和方法同样可显示本项目中的引用次数。
77
81
78
-
More on editor in [Visual Studio Code](https://code.visualstudio.com).
82
+
关于编辑器的资料可以在 [Visual Studio Code](https://code.visualstudio.com) 上查阅。
79
83
80
-
## Using the VS Code debugger
84
+
## 使用 VS Code 调试器
81
85
82
-
The sample is configured to use [Kestrel](../fundamentals/servers/kestrel.md)for the web server.
86
+
本示例配置使用 [Kestrel](../fundamentals/servers/kestrel.md)作为 Web 服务器。
83
87
84
-
Run the app in the debugger:
88
+
在调试器中运行应用:
85
89
86
-
*Tap the Debug icon in the View Bar on the left pane
90
+
*在左侧点击调试图标
87
91
88
-
*Tap the "Play (F5)" icon to launch the app
92
+
*点击「Play (F5)」图标启动应用
89
93
90
94

91
95
92
-
Your default browser will automatically launch and navigate to`http://localhost:5000`
Create a Web App in the Azure Portal to host your new application.
134
+
在 Azure 门户中添加一个 Web App 用于托管你的新应用。
131
135
132
136

133
137
134
-
Configure the Web App in Azure to support [continuous deployment using Git](https://azure.microsoft.com/en-us/documentation/articles/app-service-deploy-local-git/).
138
+
在 Azure 中配置 Web App 以便[利用 Git 持续部署](https://azure.microsoft.com/zh-cn/documentation/articles/app-service-deploy-local-git/).
135
139
136
-
Record the Git URL for the Web App from the Azure portal.
140
+
从 Azure 门户的 Web App 上记下 Git URL。
137
141
138
142

139
143
140
-
In a Terminal window, add a remote named `azure`with the Git URL you noted previously.
0 commit comments