Skip to content
返回部署

使用 AppVeyor 部署

面向 Windows 的 CI/CD 服务,支持 .NET 和 MSBuild。

CI/CD进阶

为什么

AppVeyor 提供 Windows 构建环境,预装 .NET SDK,适合 Windows 专属项目。DORA 2024 DevOps 状态报告显示精英团队部署频率比低绩效团队高 973 倍。

带自动化测试的 CI/CD 管道将变更失败率降至 5-15%,而手动部署为 40-60%。

何时使用

Windows 或 .NET 项目需要云端 CI 而不自托管 Windows runner。

如何做

# appveyor.YML version: 1.0 image: Visual Studio 2022 build_script: - dotnet build -c Release test_script: - dotnet test -c Release artifacts: - path: '**/*.nupkg' deploy: - provider: NuGet api_key: secure: $NUGET_API_KEY on: branch: main appveyor_repo_tag: true 4. 验证部署 — curl -I https://your-app.example.com 5. 监控日志 — 前 5 分钟检查错误 6. 需要时回滚 — 回退到上一版本

示例

# 部署 to Azure from AppVeyor deploy: - provider: AzureWebSite website: myapp username: $AZURE_USER password: secure: $AZURE_PASS on: branch: main

常见问题

  • ⚠构建超时 — 将测试拆分到多个 job
  • ⚠NuGet 推送失败 — 检查 API key 和包版本
  • ⚠环境间配置漂移 — 使用基础设施即代码(Terraform/Pulumi)保持 dev/staging/prod 一致

最佳实践

  • ✓用构建矩阵 — 跨 .NET 版本测试
  • ✓用 secure variable — 切勿在日志暴露密钥
  • ✓设置健康检查和优雅关闭 — 处理 SIGTERM 以在退出前排空进行中的请求

常见问题解答