dotnet-ado-patterns
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesedotnet-ado-patterns
.NET项目Azure DevOps流水线模式
Composable Azure DevOps YAML pipeline patterns for .NET projects: template references with , , , and keywords for hierarchical pipeline composition, variable groups and variable templates for centralized configuration, pipeline decorators for organization-wide policy injection, conditional insertion with and expressions, multi-stage pipelines (build, test, deploy), and pipeline triggers for CI, PR, and scheduled runs.
extendsstagesjobssteps${{ if }}${{ each }}Version assumptions: Azure Pipelines YAML schema. task for .NET 8/9/10 builds. Template expressions syntax v2.
DotNetCoreCLI@2适用于.NET项目的可组合Azure DevOps YAML流水线模式:使用、、和关键字实现分层流水线组合的模板引用,用于集中配置的变量组和变量模板,用于组织级策略注入的流水线装饰器,通过和表达式实现的条件插入,包含构建、测试、部署的多阶段流水线,以及用于CI、PR和定时运行的流水线触发器。
extendsstagesjobssteps${{ if }}${{ each }}版本说明: Azure Pipelines YAML 架构。使用任务构建.NET 8/9/10项目。模板表达式语法为v2版本。
DotNetCoreCLI@2Scope
适用范围
- Template references with extends, stages, jobs, and steps keywords
- Variable groups and variable templates for centralized configuration
- Pipeline decorators for organization-wide policy injection
- Conditional insertion with ${{ if }} and ${{ each }} expressions
- Multi-stage pipelines (build, test, deploy)
- Pipeline triggers for CI, PR, and scheduled runs
- 使用extends、stages、jobs和steps关键字的模板引用
- 用于集中配置的变量组和变量模板
- 用于组织级策略注入的流水线装饰器
- 通过和
${{ if }}表达式实现的条件插入${{ each }} - 多阶段流水线(构建、测试、部署)
- 用于CI、PR和定时运行的流水线触发器
Out of scope
不适用范围
- Starter CI templates -- see [skill:dotnet-add-ci]
- CLI release pipelines (tag-triggered build-package-release for CLI tools) -- see [skill:dotnet-cli-release-pipeline]
- ADO-unique features (environments, service connections, classic releases) -- see [skill:dotnet-ado-unique]
- Build/test specifics -- see [skill:dotnet-ado-build-test]
- Publishing pipelines -- see [skill:dotnet-ado-publish]
- GitHub Actions workflow patterns -- see [skill:dotnet-gha-patterns]
Cross-references: [skill:dotnet-add-ci] for starter templates that these patterns extend, [skill:dotnet-cli-release-pipeline] for CLI-specific release automation.
For detailed YAML examples (stage/job/step templates, extends, variable groups, conditional insertion, multi-stage pipelines, triggers), see in this skill directory.
examples.md- 入门级CI模板——请查看[skill:dotnet-add-ci]
- CLI工具发布流水线(基于标签触发的构建-打包-发布流程)——请查看[skill:dotnet-cli-release-pipeline]
- Azure DevOps独有功能(环境、服务连接、经典发布)——请查看[skill:dotnet-ado-unique]
- 构建/测试细节——请查看[skill:dotnet-ado-build-test]
- 发布流水线——请查看[skill:dotnet-ado-publish]
- GitHub Actions工作流模式——请查看[skill:dotnet-gha-patterns]
交叉引用:[skill:dotnet-add-ci]提供了本模式所基于的入门模板,[skill:dotnet-cli-release-pipeline]针对CLI工具提供了专属的发布自动化方案。
如需详细的YAML示例(阶段/作业/步骤模板、extends、变量组、条件插入、多阶段流水线、触发器),请查看本skill目录下的文件。
examples.mdAgent Gotchas
Agent注意事项
- Template parameter types are enforced at compile time -- passing a string where is expected causes a validation error before the pipeline runs; always match types exactly.
type: boolean - templates cannot be overridden -- callers cannot inject steps before or after the mandatory stages; this is by design for policy enforcement.
extends - Variable group secrets are not available in template expressions -- resolves at compile time when secrets are not yet available; use
${{ variables.mySecret }}runtime syntax instead.$(mySecret) - iterates at compile time -- the loop generates YAML before the pipeline runs; runtime variables cannot be used as the iteration source.
${{ each }} - CI and PR triggers are mutually exclusive with and
trigger: none-- omitting bothpr: noneandtriggersections enables default CI triggering on all branches; explicitly setprto disable.trigger: none - Path filters in triggers use repository root-relative paths -- do not prefix paths with or
/; use./notsrc/**../src/** - Scheduled triggers always run on the default branch first -- the filter applies after the schedule fires; the schedule itself is only evaluated from the default branch YAML.
branches.include - Pipeline resource triggers require the source pipeline name, not the YAML file path -- use the pipeline name as shown in ADO, not the file path.
azure-pipelines.yml
- 模板参数类型在编译时强制执行——如果在需要类型的位置传入字符串,会在流水线运行前触发验证错误;请确保参数类型完全匹配。
type: boolean - 模板无法被覆盖——调用方无法在强制要求的阶段前后注入步骤;这是为了策略管控而设计的。
extends - 变量组中的机密信息无法在模板表达式中使用——在编译时解析,此时机密信息尚未可用;请改用
${{ variables.mySecret }}运行时语法。$(mySecret) - 循环在编译时执行——循环会在流水线运行前生成YAML内容;运行时变量不能作为迭代源。
${{ each }} - CI和PR触发器与和
trigger: none互斥——如果同时省略pr: none和trigger配置段,会启用所有分支的默认CI触发;如需禁用请显式设置pr。trigger: none - 触发器中的路径筛选器使用相对于仓库根目录的路径——不要给路径添加或
/前缀;请使用./而非src/**。./src/** - 定时触发器始终先在默认分支上运行——筛选器在定时任务触发后生效;定时任务本身仅从默认分支的YAML文件中读取配置。
branches.include - 流水线资源触发器需要指定源流水线的名称,而非YAML文件路径——请使用Azure DevOps中显示的流水线名称,而非文件路径。
azure-pipelines.yml