Skip to content

Commit 59fff89

Browse files
committed
更新 your-first-mac-aspnet.md 翻译
1 parent c23f7d4 commit 59fff89

File tree

1 file changed

+58
-54
lines changed

1 file changed

+58
-54
lines changed
Lines changed: 58 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
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
33
author: spboyer
44
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
55
keywords: ASP.NET Core, macOS, Yeoman, generator-aspnet, Visual Studio Code, Linux, VS Code
@@ -12,26 +12,30 @@ ms.technology: aspnet
1212
ms.prod: asp.net-core
1313
uid: tutorials/your-first-mac-aspnet
1414
---
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 应用程序
1616

17-
This article will show you how to write your first ASP.NET Core application on macOS or Linux.
17+
翻译:[刘怡(AlexLEWIS)](http://github.com/alexinea)[赵志刚](https://github.com/rdzzg)
1818

19-
## Setting up your development environment
19+
本文将展示如何在 macOS 或 Linux 平台上创建首个 ASP.NET Core 应用程序。
2020

21-
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+
## 配置开发环境
2222

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)
2424

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` 参数作为模板类型。
2632

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.
2933

3034
```console
3135
dotnet new mvc
3236
```
3337

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 命令完成,会生成下列输出和文件。
3539

3640
```console
3741
Content generation time: 79.6691 ms
@@ -43,117 +47,117 @@ The template "Empty ASP.NET Core Web Application" created successfully.
4347

4448
[!INCLUDE[template files](../includes/template-files.md)]
4549

46-
## Developing ASP.NET Core applications on a Mac and Linux with Visual Studio Code
50+
## 在 macOS 和 Linux 上使用 Visual Studio Code 开发 ASP.NET 应用程序
4751

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 CodeVS Code)打开项目文件夹,然后选择 *Startup.cs* 文件。VS Code 将立即还原(restore)项目所需的依赖项,并添加生成/调试依赖项。点击 **Yes** 添加生成和调试资源,然后点击 **Restore** 来还原项目依赖。
4953

5054
![Info messages: 2. 2. Required assets to build and debug are missing from your project. Add them?](your-first-mac-aspnet/_static/debug-add-items-prompt.png)
5155

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`,如下所示:
5357

5458
![Command bar showing autocompletion option on typing 'dot' for 'dotnet: Restore Packages'](your-first-mac-aspnet/_static/dot-restore.png)
5559

56-
VS Code provides a streamlined, clean interface for working with files and a productive coding enviromment.
60+
VS Code 为工作文件和生产代码环境提供了流畅简洁的界面。
5761

58-
In the left navigation bar, there are five icons, representing four viewlets:
62+
左侧导航栏中的四个图标分别代表五种功能:
5963

60-
* Explore
61-
* Search
64+
* 资源管理器
65+
* 搜索
6266
* Git
63-
* Debug
64-
* Extensions
67+
* 调试
68+
* 扩展
6569

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.
70+
资源管理器视图提供了文件导航与已开文件视图。它会使用一个符号来表示未保存变更的文件。在该视图中可以创建文件和文件夹。如果鼠标经过菜单项,**全部保存(Save All**按钮就会出现,点击即可保存全部变更。
6771

68-
The Search viewlet allows you to search the folder tree of files you have open. The search is for filenames and file contents.
72+
搜索视图允许在已开文件的目录树下搜索文件名及内容。
6973

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.
74+
如果你电脑已安装 Git,那么 *VS Code* 将直接集成 Git,你可以在 Git 视图中初始化一个新仓库,提交(Commit)并推送(Push)变更。
7175

7276
![GIT sidebar indicating 'This workspace isn't yet under git source control' with an 'Initialize git repository' button](your-first-mac-aspnet/_static/vscode-git.png)
7377

74-
The Debug viewlet supports interactive debugging of applications.
78+
调试视图支持为应用程序进行交互式调试。
7579

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 + .` 自动移除之。类和方法同样可显示本项目中的引用次数。
7781

78-
More on editor in [Visual Studio Code](https://code.visualstudio.com).
82+
关于编辑器的资料可以在 [Visual Studio Code](https://code.visualstudio.com) 上查阅。
7983

80-
## Using the VS Code debugger
84+
## 使用 VS Code 调试器
8185

82-
The sample is configured to use [Kestrel](../fundamentals/servers/kestrel.md) for the web server.
86+
本示例配置使用 [Kestrel](../fundamentals/servers/kestrel.md) 作为 Web 服务器。
8387

84-
Run the app in the debugger:
88+
在调试器中运行应用:
8589

86-
* Tap the Debug icon in the View Bar on the left pane
90+
* 在左侧点击调试图标
8791

88-
* Tap the "Play (F5)" icon to launch the app
92+
* 点击「Play (F5)」图标启动应用
8993

9094
![DEBUG sidebar showing the triangle play button](your-first-mac-aspnet/_static/launch-debugger.png)
9195

92-
Your default browser will automatically launch and navigate to `http://localhost:5000`
96+
默认浏览器自动启动并访问 `http://localhost:5000`
9397

9498
![Browser window](your-first-mac-aspnet/_static/myfirstapp.png)
9599

96-
* To stop the application, close the browser and hit the "Stop" icon on the debug bar
100+
* 关闭浏览器并在调试栏中点击「Stop」图标,应用停止运行。
97101

98102
![VS Code Debug bar](your-first-mac-aspnet/_static/debugger.png)
99103

100-
### Using the dotnet commands
104+
### 使用 dotnet 指令
101105

102-
* Run `dotnet run` command to launch the app from terminal/bash
106+
* 在终端或 bash 上运行 `dotnet run` 指令启动应用。
103107

104-
* Navigate to `http://localhost:5000`
108+
* 浏览器中访问 `http://localhost:5000`
105109

106-
* To stop the web server enter `⌃+C` or `Ctrl+C`.
110+
* 通过 `⌃+C` `Ctrl+C` 停止 web 服务器。
107111

108-
## Publishing to Azure
112+
## 发布到 Azure
109113

110-
VS Code provides Git integration to push updates to production, hosted on [Microsoft Azure](http://azure.microsoft.com).
114+
VS Code 提供了 Git 的集成,可用来提送更新到托管于[Microsoft Azure](http://azure.microsoft.com)的生产环境。
111115

112-
### Initialize Git
116+
### 初始化 Git
113117

114-
Initialize Git in the folder you're working in. Tap on the Git viewlet and click the `Initialize Git repository` button.
118+
为你的工作文件夹初始化 GIT。切换到Git视图 然后点击 `Initialize Git repository` 按钮。
115119

116120
![GIT sidebar](your-first-mac-aspnet/_static/vscode-git-commit.png)
117121

118-
Add a commit message and tap enter or tap the checkmark icon to commit the staged files.
122+
填写提交信息并点击提交,或点击复选框来提交暂存文件。
119123

120124
![GIT sidebar showing file changes](your-first-mac-aspnet/_static/init-commit.png)
121125

122-
Git is tracking changes, so if you make an update to a file, the Git viewlet will display the files that have changed since your last commit.
126+
Git 会跟踪变更,所以如果你更新了文件,Git视图将显示上次提交之后修改过的文件。
123127

124-
### Initialize Azure Website
128+
### 初始化 Azure 网站
125129

126-
You can deploy to Azure Web Apps directly using Git.
130+
你可以直接通过 Git 来部署 Azure Web Apps
127131

128-
* If you don't have an Azure account, you can [create a free trial](http://azure.microsoft.com/en-us/pricing/free-trial/).
132+
* 若你没有 Azure 账号,你可以[免费试用](http://azure.microsoft.com/en-us/pricing/free-trial/).
129133

130-
Create a Web App in the Azure Portal to host your new application.
134+
在 Azure 门户中添加一个 Web App 用于托管你的新应用。
131135

132136
![Microsoft Azure Portal: New button: Web + Mobile selection in the Marketplace list reveals a Web App button under Featured Apps](your-first-mac-aspnet/_static/create-web-app.png)
133137

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/).
135139

136-
Record the Git URL for the Web App from the Azure portal.
140+
从 Azure 门户的 Web App 上记下 Git URL。
137141

138142
![Azure Portal for web application: Overview panel](your-first-mac-aspnet/_static/azure-portal.png)
139143

140-
In a Terminal window, add a remote named `azure` with the Git URL you noted previously.
144+
在终端窗口,用你之前记下的 Git URL 创建一个新的名为 `azure` 的远成仓库。
141145

142146
`git remote add azure https://[email protected]:443/MyFirstAppMac.git`
143147

144-
Push to master. `git push azure master` to deploy.
148+
推送(Push)到 master 分支,用 `git push azure master` 部署。
145149

146150
![Command window showing a successful deployment](your-first-mac-aspnet/_static/git-push-azure-master.png)
147151

148-
Browse to the newly deployed web app.
152+
浏览新发布的网络应用
149153

150154
![Browser window](your-first-mac-aspnet/_static/azure.png)
151155

152-
Looking at the Deployment Details in the Azure Portal, you can see the logs and steps each time there is a commit to the branch.
156+
在 Azure 门户上查看部署详情(Deployment Details),你可以看到分支提交的每一个步骤和日志。
153157

154158
![Azure Portal for web application: Deployment Details](your-first-mac-aspnet/_static/deployment.png)
155159

156-
## Additional resources
160+
## 更多信息
157161

158162
* [Visual Studio Code](https://code.visualstudio.com)
159-
* [Fundamentals](../fundamentals/index.md)
163+
* [基本原理](../fundamentals/index.md)

0 commit comments

Comments
 (0)