Bitzsoft.Integrations.ProjectManagement.AzureDevOps
1.0.4
dotnet add package Bitzsoft.Integrations.ProjectManagement.AzureDevOps --version 1.0.4
NuGet\Install-Package Bitzsoft.Integrations.ProjectManagement.AzureDevOps -Version 1.0.4
<PackageReference Include="Bitzsoft.Integrations.ProjectManagement.AzureDevOps" Version="1.0.4" />
<PackageVersion Include="Bitzsoft.Integrations.ProjectManagement.AzureDevOps" Version="1.0.4" />
<PackageReference Include="Bitzsoft.Integrations.ProjectManagement.AzureDevOps" />
paket add Bitzsoft.Integrations.ProjectManagement.AzureDevOps --version 1.0.4
#r "nuget: Bitzsoft.Integrations.ProjectManagement.AzureDevOps, 1.0.4"
#:package Bitzsoft.Integrations.ProjectManagement.AzureDevOps@1.0.4
#addin nuget:?package=Bitzsoft.Integrations.ProjectManagement.AzureDevOps&version=1.0.4
#tool nuget:?package=Bitzsoft.Integrations.ProjectManagement.AzureDevOps&version=1.0.4
Bitzsoft.Integrations.ProjectManagement.AzureDevOps
Azure DevOps Boards REST API 项目与敏捷工单连接器实现。遵循项目管理通用抽象规范,实现 IProjectManagementService 接口与专属的 IAzureDevOpsProjectManagementService 扩展接口。
功能特性
- 通用契约对齐:实现
IProjectManagementService,支持任务创建、详情获取、信息更新、任务完成与多条件分页检索。 - PAT 个人访问令牌鉴权:支持 Azure DevOps 云端(
https://dev.azure.com/{organization})与私有部署(Azure DevOps Server / TFS),支持 Basic 认证标头构造。 - WIQL 原生查询支持:支持 Work Item Query Language (WIQL) 灵活查询语法,支持跨迭代、跨状态的高级筛选与批量 ID 解析。
- 原生工作项(Work Items)全生命周期:支持基于字段字典(
IDictionary<string, object?>)动态增删改工作项(Task、Bug、User Story、Epic、Feature 等)。 - 评论流(Comments)交互:支持工作项讨论评论的追加发布与历史记录读取。
- 团队协作发现:支持组织级与项目级敏捷团队(Teams)列表检索。
- 私有部署兼容性:支持自签名 SSL 证书信任配置(
AllowInsecureCertificates)。 - 工业级弹性韧性:集成 Polly 标准韧性管道(429/503 指数退避重试与熔断保护)及全量出站请求审计日志(
RequestLogging)。
安装
dotnet add package Bitzsoft.Integrations.ProjectManagement.AzureDevOps
<PackageReference Include="Bitzsoft.Integrations.ProjectManagement.AzureDevOps" Version="1.0.0" />
配置
在 appsettings.json 中配置 Azure DevOps 连接器参数:
{
"ProjectManagement": {
"AzureDevOps": {
"BaseUrl": "https://dev.azure.com/my-organization",
"Organization": "my-organization",
"PersonalAccessToken": "your-azure-devops-pat-token",
"DefaultProject": "my-project",
"ApiVersion": "7.0",
"AllowInsecureCertificates": false,
"UserAgent": "Bitzsoft-AzureDevOps/1.0"
}
}
}
配置项说明
| 配置键 | 类型 | 默认值 | 说明 |
|---|---|---|---|
BaseUrl |
string |
https://dev.azure.com |
Azure DevOps 组织或服务基地址。如 https://dev.azure.com/{organization} 或私有 TFS 地址。 |
Organization |
string? |
null |
组织名称。若 BaseUrl 已包含组织路径则可省略。 |
PersonalAccessToken |
string |
"" |
个人访问令牌(PAT),需具备 Work Items (Read & Write) 权限。 |
DefaultProject |
string? |
null |
默认项目名称或标识(当业务请求未指定 Project 时生效)。 |
ApiVersion |
string |
"7.0" |
Azure DevOps REST API 版本。 |
AllowInsecureCertificates |
bool |
false |
是否信任自签名 SSL 证书(适用于私有部署或测试环境)。 |
UserAgent |
string? |
null |
自定义 HTTP User-Agent 标头。 |
注册服务
支持通过配置源绑定或委托方式进行依赖注入注册:
using Microsoft.Extensions.DependencyInjection;
// 方式 1:通过 IConfiguration 绑定注册(推荐,默认读取 ProjectManagement:AzureDevOps)
services.AddBitzsoftAzureDevOpsProjectManagement(configuration);
// 自定义配置节路径:
// services.AddBitzsoftAzureDevOpsProjectManagement(configuration, "Integrations:AzureDevOps");
// 方式 2:通过委托手动配置注册
services.AddBitzsoftAzureDevOpsProjectManagement(options =>
{
options.BaseUrl = "https://dev.azure.com/my-organization";
options.Organization = "my-organization";
options.PersonalAccessToken = "your-azure-devops-pat-token";
options.DefaultProject = "my-project";
options.ApiVersion = "7.0";
options.AllowInsecureCertificates = false;
});
使用示例(通用 IProjectManagementService)
以下代码演示如何在业务类中通过依赖注入使用通用的 IProjectManagementService 契约操作 Azure DevOps 工作项:
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Bitzsoft.Integrations.ProjectManagement;
using Bitzsoft.Integrations.ProjectManagement.Dtos;
using TaskStatus = Bitzsoft.Integrations.ProjectManagement.Dtos.TaskStatus;
namespace YourNamespace;
public class AzureDevOpsTaskAppService
{
private readonly IProjectManagementService _pmService;
public AzureDevOpsTaskAppService(IProjectManagementService pmService)
{
_pmService = pmService;
}
public async Task<PmTask> CreateIssueAsync(
string projectName,
string title,
string description,
string? assigneeEmail = null,
DateTimeOffset? dueDate = null,
CancellationToken cancellationToken = default)
{
var request = new CreateTaskRequest
{
ProjectId = projectName,
Name = title,
Description = description,
AssigneeId = assigneeEmail,
DueDate = dueDate,
Priority = TaskPriority.High
};
return await _pmService.CreateTaskAsync(request, cancellationToken);
}
public async Task<PmTask> GetTaskAsync(
string taskId,
CancellationToken cancellationToken = default)
{
return await _pmService.GetTaskAsync(taskId, cancellationToken);
}
public async Task<List<PmTask>> ListActiveTasksAsync(
string projectName,
CancellationToken cancellationToken = default)
{
var request = new ListTasksRequest
{
ProjectId = projectName,
Status = TaskStatus.InProgress,
PageIndex = 1,
PageSize = 20
};
return await _pmService.ListTasksAsync(request, cancellationToken);
}
public async Task<PmResult> CompleteTaskAsync(
string taskId,
CancellationToken cancellationToken = default)
{
return await _pmService.CompleteTaskAsync(taskId, cancellationToken);
}
}
专有扩展能力(IAzureDevOpsProjectManagementService)
当需要使用 Azure DevOps Boards 原生特有能力(如 WIQL 高级检索、动态字段字典操作、工作项评论管理、团队列表)时,可直接注入专属接口 IAzureDevOpsProjectManagementService:
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Bitzsoft.Integrations.ProjectManagement.AzureDevOps;
using Bitzsoft.Integrations.ProjectManagement.AzureDevOps.Dtos;
namespace YourNamespace;
public class AzureDevOpsAdvancedService
{
private readonly IAzureDevOpsProjectManagementService _devOpsService;
public AzureDevOpsAdvancedService(IAzureDevOpsProjectManagementService devOpsService)
{
_devOpsService = devOpsService;
}
public async Task<List<AzureDevOpsWorkItem>> QueryBugsByWiqlAsync(
string project,
CancellationToken cancellationToken = default)
{
var wiql = "SELECT [System.Id], [System.Title], [System.State] " +
"FROM WorkItems " +
"WHERE [System.WorkItemType] = 'Bug' AND [System.State] <> 'Closed' " +
"ORDER BY [System.CreatedDate] DESC";
var wiqlResult = await _devOpsService.QueryByWiqlAsync(project, wiql, cancellationToken);
var workItemIds = new List<int>();
foreach (var itemRef in wiqlResult.WorkItems)
{
workItemIds.Add(itemRef.Id);
}
if (workItemIds.Count == 0)
{
return new List<AzureDevOpsWorkItem>();
}
return await _devOpsService.GetWorkItemsBatchAsync(project, workItemIds, cancellationToken);
}
public async Task<AzureDevOpsWorkItem> CreateUserStoryWithCustomFieldsAsync(
string project,
string title,
string description,
string areaPath,
CancellationToken cancellationToken = default)
{
var fields = new Dictionary<string, object?>
{
["System.Title"] = title,
["System.Description"] = description,
["System.AreaPath"] = areaPath
};
return await _devOpsService.CreateWorkItemAsync(project, "User Story", fields, cancellationToken);
}
public async Task<AzureDevOpsComment> AddCommentToWorkItemAsync(
string project,
int workItemId,
string commentText,
CancellationToken cancellationToken = default)
{
return await _devOpsService.AddWorkItemCommentAsync(project, workItemId, commentText, cancellationToken);
}
public async Task<List<AzureDevOpsTeam>> GetProjectTeamsAsync(
string project,
CancellationToken cancellationToken = default)
{
return await _devOpsService.ListTeamsAsync(project, cancellationToken);
}
}
依赖
| 包 | 说明 |
|---|---|
| Bitzsoft.Integrations.ProjectManagement | 项目管理服务统一抽象层 |
| Bitzsoft.Integrations.Core | 公共基座与供应商解析机制 |
| Bitzsoft.Integrations.Compatibility | 多目标框架兼容性工具集 |
| Bitzsoft.Integrations.RequestLogging | 出站请求审计与耗时追踪日志 |
相关包
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 is compatible. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Bitzsoft.Integrations.Compatibility (>= 1.0.4)
- Bitzsoft.Integrations.Core (>= 1.0.4)
- Bitzsoft.Integrations.ProjectManagement (>= 1.0.4)
- Bitzsoft.Integrations.RequestLogging (>= 1.0.4)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.10)
- Microsoft.Extensions.Http (>= 10.0.10)
- Microsoft.Extensions.Http.Resilience (>= 10.7.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.10)
-
net5.0
- Bitzsoft.Integrations.Compatibility (>= 1.0.4)
- Bitzsoft.Integrations.Core (>= 1.0.4)
- Bitzsoft.Integrations.ProjectManagement (>= 1.0.4)
- Bitzsoft.Integrations.RequestLogging (>= 1.0.4)
- Microsoft.Extensions.Configuration.Abstractions (>= 5.0.0)
- Microsoft.Extensions.Http (>= 5.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 5.0.0)
-
net8.0
- Bitzsoft.Integrations.Compatibility (>= 1.0.4)
- Bitzsoft.Integrations.Core (>= 1.0.4)
- Bitzsoft.Integrations.ProjectManagement (>= 1.0.4)
- Bitzsoft.Integrations.RequestLogging (>= 1.0.4)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.10)
- Microsoft.Extensions.Http (>= 10.0.10)
- Microsoft.Extensions.Http.Resilience (>= 10.7.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.10)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Bitzsoft.Integrations.ProjectManagement.AzureDevOps:
| Package | Downloads |
|---|---|
|
Bitzsoft.Integrations.ProjectManagement.All
项目管理服务聚合包 — 包含全部供应商实现(Asana / Teambition / Monday / Trello / ONES / PingCode / Yunxiao / GitHub / GitLab / Gitee / JiraCloud / JiraDataCenter / AzureDevOps / Tapd) |
GitHub repositories
This package is not used by any popular GitHub repositories.