.NET Framework华为云流水线发布

文章目录


前言

华为云流水线发布:自动检查代码,打包发布到服务器


一、新建代码检查

检查代码是否存在报错

设置规则集

二、新建编译构建







三、新建部署

模板选择空模板或者自己去创建自定义模板

bash 复制代码
$directory = "${ProjectFile}"; if (-not (Test-Path -Path $directory)) { New-Item -Path $directory -ItemType Directory }


bash 复制代码
$siteName = "dev"  # 替换成你的网站名称

$site = Get-Website -Name $siteName

if ($site.State -eq "Started") {
    C:\Windows\System32\inetsrv\appcmd.exe stop apppool /apppool.name:$siteName;
    Stop-Website -Name $siteName;
    Write-Host "The website $siteName has been stopped";
} else {
    Write-Host "The website $siteName is in an unknown state"
}
bash 复制代码
#上面截图:同时发布的两个站点,所以和下面的代码是不一样的,下面的去掉了一个站点
# 定义源文件路径和目标文件夹路径
$sourceFilePath = "${ProjectFile}/"
$destinationFolderPath = "D:/work/WebBackUp/service/${Project}/"

# 获取当前时间戳
$timestamp = Get-Date -Format "yyyyMMdd_HHmmss"

# 构建目标文件路径
$destinationFilePath = Join-Path -Path $destinationFolderPath -ChildPath "file_$timestamp"

# 确保目标文件夹存在
if (-not (Test-Path -Path $destinationFolderPath)) {
    New-Item -ItemType Directory -Path $destinationFolderPath
}

# 删除目标文件夹中的所有文件和子文件夹
Remove-Item -Path (Join-Path -Path $destinationFolderPath -ChildPath "*") -Recurse -Force

# 复制 $sourceFilePath 文件
Copy-Item -Path $sourceFilePath -Destination $destinationFilePath -Recurse -Force

删除文件根据自己需要添加,不再一 一截图了

bash 复制代码
#上面截图:同时发布的两个站点,所以和下面的代码是不一样的,下面的去掉了一个站点

Copy-Item -Path D:/AppPackage/${Project}/${Time}/_PublishedWebsites/Web/* -Destination ${ProjectFile} -Recurse -Force
bash 复制代码
#上面截图:同时发布的两个站点,所以和下面的代码是不一样的,下面的去掉了一个站点
$siteName = "dev"  # 替换成你的网站名称

$site = Get-Website -Name $siteName

if ($site.State -eq "Stopped") {
    C:\Windows\System32\inetsrv\appcmd.exe start apppool /apppool.name:$siteName;
    Start-Website -Name $siteName;
    Write-Host "The website $siteName is running";
} else {
    Write-Host "The website $siteName is in an unknown state"
}


三、新建流水线


模板选择空模板




相关推荐
智商偏低5 天前
ASP.NET Core 中的简单授权
后端·asp.net
九河云5 天前
华为云 GaussDB:金融级高可用数据库,为核心业务保驾护航
网络·数据库·科技·金融·华为云·gaussdb
zcy·5 天前
华为云/本地化部署K8S-查看容器日志
华为云
是萝卜干呀7 天前
IIS 部署 asp.net core 项目时,出现500.19、500.31问题的解决方案
后端·iis·asp.net·hosting bundle
记录Java学习的三木7 天前
中州养老:华为云设备管理接口开发全流程
华为云
速易达网络9 天前
ASP.NET MVC 连接 MySQL 数据库查询示例
数据库·asp.net·mvc
智商偏低9 天前
ASP.NET Core 身份验证概述
后端·asp.net
冷冷的菜哥9 天前
ASP.NET Core使用MailKit发送邮件
后端·c#·asp.net·发送邮件·mailkit
DS小龙哥11 天前
基于华为云的STM32F103C8T6智能停车场管理系统
大数据·stm32·华为云
冷冷的菜哥13 天前
ASP.NET Core文件分片上传
c#·asp.net·asp.net core·文件分片上传