Azure DevOps Server |Azure DevOps Server 2022
小窍门
有关最新的扩展开发指南,包括从 VSS.SDK 的主题设置和迁移,请参阅 Azure DevOps 扩展 SDK 开发人员门户。
重要
本文仅适用于 Azure DevOps Server(本地)。 对于 Azure DevOps Services,请改为通过 继承过程模型 自定义工作项表单。
可以使用该工具将工作项类型导出为 XML witadmin ,其中包括工作项窗体的布局。 在本示例中,我们将添加页面、组和控件对布局的贡献。 我们还将控件添加到敏捷“用户情景”工作项类型。 有关详细信息,请参阅 WebLayout xml 参考。
在工作项窗体中添加扩展
在 Azure DevOps Server 中安装工作项表单扩展。
打开
Developer Command Prompt。 使用以下命令将 xml 文件导出到桌面。witadmin exportwitd /collection:CollectionURL /p:Project /n:TypeName /f:FileName在指定的目录中创建一个文件。
在此文件中,转到 “WebLayout ”部分。 在 WebLayout 节中,一个注释块指定哪些已安装扩展适用于集合中的工作项表单。 对于每个扩展,其所有表单贡献都列有其 ID 和输入(如果它是控制贡献)。 在以下示例中,注释显示在集合上安装了 color-control-dev 扩展。 该扩展有一个控制贡献,需要两个输入。
<!--**********************************Work Item Extensions*************************** Extension: Name: color-control-dev Id: example.color-control-dev Control contribution: Id: example.color-control-dev.color-control-contribution Description: Inputs: Id: FieldName Description: The field associated with the control. Type: Field IsRequired: true Id: Colors Descriptions: The colors that match the values in the control. Type: String IsRequired: false在 “工作项扩展 ”部分中查找扩展 ID:
<!--**********************************Work Item Extensions*************************** Extension: Name: color-control-dev Id: example.color-control-dev ...在 “工作项扩展 ”部分下面添加扩展标记,如下所示,使扩展可供工作项窗体使用。 若要在窗体中放置输入,必须在
Extensions部分指定其扩展名。<!--**********************************Work Item Extensions*************************** ... Note: For more information on work item extensions use the following topic: https://go.microsoft.com/fwlink/?LinkId=816513 --> <Extensions> <Extension Id="example.color-control-dev" /> </Extensions>在 xml 中指定扩展会自动将扩展中定义的 页面 和 组 贡献放入窗体中。 可以在以下示例中移动贡献内容。
添加页面贡献
<Page Id="Details">
<PageContribution Id="<page contribution id>" />
...
添加组贡献
<Page Id="Details">
...
<Section>
...
<GroupContribution Id="<group contribution id>" />
...
页面贡献和组贡献不能采用任何其他布局元素。
添加控制组件
与 页面 和 组 贡献不同,在 xml 中指定扩展不会自动放置 控件 贡献。 若要在表单中添加这些贡献,请使用贡献标记将其添加到表单中。 以下示例将 ControlContribution 添加到 规划 组。
如果控件贡献定义了任何必需的输入,则用户必须为该输入提供值。 对于任何非必需的输入,用户可以决定是否将值设置给该输入。 在以下示例中,FieldName 和 Colors 输入已设置。
<Page Id="Details">
...
<Section>
...
<Group Id="Planning">
...
<ControlContribution Label="Priority" Id="example.color-control-dev.color-control-contribution">
<Inputs>
<Input Id="FieldName" Value="Microsoft.Azure DevOps Services.Common.Priority" />
<Input Id="Colors" Value="red;green" />
</Inputs>
</ControlContribution>
<Control Label="Risk" Type="FieldControl" FieldName="Microsoft.Azure DevOps Services.Common.Risk" />
导入此 xml 文件,使用
witadmin。witadmin importwitd /collection:CollectionURL /p:Project /f:FileName
你的扩展是通过工作项表单进行配置的!