[Huawei cloud combat development] 8. How quickly build C # Web site and implement continuous integration? [Share] Huawei Cloud

1 Overview

The purpose of Article 1.1

This article describes how to use an instance of software development services DevCloud completed the development of a C # Web projects.

1.2 Project Details

Picture 1.png

1. Project Name: super joke website

2. Project: a Web site that contains user login and registration visit the website jokes and other functions.

3. The development of programming languages: ASP.NET MVC5 (C #)

4. Project Type: Web-based ASP.NET project of B / S architecture

5. deployment environment: Windows + IIS + MySql

6. deployment: template deployment

Picture 2.png

A typical B / S architecture system, users access the system via the Internet, the client user operation, and read or write data to the database.

1.3 Process trunk

This article is the backbone of the process: code hosting, build compile, publish (publish software library), deployment.

Developer version management by code hosting service in the local development. After the project is developed to a certain extent it can be compiled to build operate, build the package, archive management by publishing service. And then deploy the package to the server can be accessed via the outside.

Picture 3.png

1.4 Prerequisites

Sign Huawei cloud account: Huawei cloud official website registered Huawei cloud account, this account is applicable to all Huawei's cloud offerings.

Elastic Cloud Server: the deployment will use the ECS with the public IP network (Windows Sever 2012).

2 Project Management

2.1 Creating project

New project development process consists of two types: scrum processes, Kanban processes. Scrum agile development process is a standard process, item-level work for the traditional scrum division method Epic-> Feature-> Story-> Task & Bug, this project is the level of work into a clearer, choose the scrum process.

Picture 4.png

2.2 Creating iteration

The project development cycle is short, only one release, is divided into three iterations, iterative cycles of one week.

Picture 5.png

2.3 梳理产品需求清单

项目规划是以思维导图的形式将工作项的层级结构展示出来,更直观的看到父子关系,在项目规划中新建工作项后,会自动生成到后面的Epic,Feature,Backlog和迭代页面,在迭代开始前,项目经理将从客户获取的所有需求信息,逐一落实到项目规划中,分解成story,并为工作项设置优先级。

Picture 6.png

3 代码托管

3.1 创建仓库

Ø 新建代码仓库时,选择“模板新建”,在搜索框中输入已经被公开为示例模板的仓库名称,选择该模板。(此处搜索“superjokes”,编程语言选择ASP.NET)

Pictures 7.png

Ø 输入新的仓库名称(可以和模板仓库同名),即可创建代码仓

Picture 8.png

数据库密码修改:(必做,否则将不会部署成功)

修改在superjokes/src/Joke.Web/App_Data目录下的appsettings.config。将数据库配置处的密码(第33行Password=)改为将要部署的主机上的数据库密码。

Pictures 9.png

4 编译构建

4.1 创建构建任务

Ø 新建任务,在“选择构建模板”界面勾选msbuild,点击确定完成任务模板的创建。跳转至“编译构建任务”界面。

Picture 10.png

Ø 输入构建详细信息

任务描述、源码仓库分支等自行选择。

Picture 11.png

Ø Msbuild构建

Msbuild构建流程,使用镜像msbuild15-all

Pictures .png

Pictures .png

5 发布

本项目中发布服务可以将构建生成的可执行文件上传到发布仓库,便于软件包管理。

Ø 版本归档

Msbuild构建过程中已经写了对应的压缩指令。

在“上传软件包到发布库(Windows环境)”步骤写明构建包路径、发布版本号及包名后,可以将构建生成的软件包上传到发布仓库,自动进行软件版本管理。

Pictures .png

6 部署

部署任务的目的是将构建完成的软件包部署到一个可供我们访问的服务器上,部署成功之后即可通过浏览器访问该地址。

部署任务一共分为四部分,分别是主机授信,编写部署脚本,任务配置,和执行部署。

Picture 14.png

此时需要一台可供访问的服务器,由于此次部署的Web工程是C#语言编写的,所以服务器需要是一台具有弹性ip地址的Windows服务器。

在主机授信前,需要先对主机环境进行相应配置。

6.1 主机环境配置

1. 安装MySQL。

2. 通过数据库配置脚本在服务器上生成MySQL数据库,数据库配置脚本为位于代码仓库根目录的superjokes.sql。

Picture 15.png

6.2 主机授信

 

将服务器主机授信到DevCloud里,用于部署网站。

点击“设置-通用设置-主机组管理”,将服务器以主机组的形式授信到项目当中。

Pictures .png

 

新建主机组:

Pictures .png

在主机组中添加主机:

Pictures .png

6.3 模板部署任务

Ø 新建模板部署任务。

Ø 填写部署任务名称,不使用模板直接创建。

Pictures .png

 

Ø 添加以下部署步骤:选择部署来源、解压文件、删除文件、执行PowerShell脚本

(1) 选择部署来源:(将软件包传到云主机上)

Pictures .png

(2) 解压文件:(将传输完毕的软件包解压到指定路径)

(3) 删除文件:(将传输到主机的软件包删除)

(4) 执行PowerShell脚本:(PowerShell脚本位于解压目录即superjokes路径的根目录下)

Pictures .png

 

PowerShell参数详解:(按顺序依次,中间以空格分开)

注:下图为web.ps1中的参数定义部分代码片段。PowerShell脚本参数中,Windows系统下路径的“\”需要以“\\”替换。

Pictures .png

1.sitePort: 网站端口(提供一个目标主机上可访问的端口号)

2.SiteName: 网站名称,启动IIS服务时为该网站命名

3.SiteAppPoolsModel: Integrated 不必修改

4.managedRuntimeVersion: v4.0 不必修改

5.WebSitePath: IIS服务中网站源文件路径

Log storage path IIS service: 6.IISLogFile

Ø Save the deployment tasks and perform the task.

 

View 6.4 deployment effect

After the completion of the deployment of task execution can use http: // ip: port / default page visit site

Picture 23.png

This, we completed a C # web project in DevCloud build on.

 

Huawei cloud DevCloud, within the following limits range 5, free to use, and can reserve a free product demonstrations and technical exchanges, to see details of Huawei's cloud official website

Guess you like

Origin www.cnblogs.com/huaweicloud/p/12018198.html