.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"
}


三、新建流水线


模板选择空模板




相关推荐
William_cl1 天前
【C#/.NET 进阶】ASP.NET 架构与最佳实践:DI 依赖注入(IoC 核心)从入门到避坑
c#·asp.net·.net
FairGuard手游加固4 天前
双云权威认证|FairGuard游戏加固上架华为云、阿里云商店
游戏·阿里云·华为云
医疗信息化王工8 天前
基于ASP.NET Core的医院不良事件管理系统的架构设计
后端·asp.net
L·S·P9 天前
OpenCode添加第三方连接服务及模型
ai·华为云·ai编程·大模型编程·opencode
余衫马10 天前
在 Windows 服务中托管 ASP.NET Core Web API (.net6)
运维·windows·后端·asp.net·.net
数数科技的数据干货10 天前
ThinkingAI携手华为云,共建企业级AI Agent平台Agentic Engine
人工智能·ai·华为云·agent
波波00715 天前
ASP.NET Core 健康检查实战:不只是一个 /health 接口
后端·asp.net
csdn_aspnet16 天前
了解 ASP.NET Core 中的防伪技术
后端·asp.net·csrf·.net core
叫我黎大侠16 天前
.NET 实战:调用千问视觉模型实现 OCR(车票识别完整教程)
阿里云·ai·c#·ocr·asp.net·.net·.netcore
Yana.nice18 天前
华为云计算(FusionAccess/FusionCompute/OpenStack)平台
华为云·openstack