简体   繁体   English

如何通过PowerShell更改TFS WIT

[英]How to Change TFS WIT via PowerShell

I have PowerShell code that exports my Bug and Test Cases WIT's into a folder, but I want to add new data to the XML. 我有将我的Bug和测试用例WIT导出到一个文件夹中的PowerShell代码,但是我想向XML添加新数据。 So I would want to add a new version number each time but not remove any of the existing data eg Next version is 1.1.0.2205. 因此,我想每次都添加一个新的版本号,但不删除任何现有数据,例如,下一版本为1.1.0.2205。 I already have the code to import the WIT but this is where I am struggling. 我已经有导入WIT的代码,但这就是我在努力的地方。 Any help would be much appreciated 任何帮助将非常感激

Here is how the Bug WIT looks like and where I want to add the data: 以下是Bug WIT的外观以及我要添加数据的位置:

<FIELD name="Detected in Version" refname="Example.DetectedInVersion" type="String" reportable="dimension">
    <SUGGESTEDVALUES expanditems="true">
      <LISTITEM value="1.2107.0.0" />
      <LISTITEM value="1.2201.0.0" />
      <LISTITEM value="1.1.0.2202" />
      <LISTITEM value="1.1.0.2203" />
      <LISTITEM value="1.1.0.2204" />
    </SUGGESTEDVALUES>
    <REQUIRED />
  </FIELD>

I would avoid changing the WIT every type, use a GlobalList instead. 我将避免更改每种类型的WIT,而应使用GlobalList。 Your definition becomes 您的定义变为

<FIELD name="Detected in Version" refname="Example.DetectedInVersion" type="String" reportable="dimension">
    <SUGGESTEDVALUES expanditems="true">
      <GLOBALLIST name="MyListOfVersions" />
    </SUGGESTEDVALUES>
    <REQUIRED />
  </FIELD>

the global list is defined in another XML file like this 全局列表是在这样的另一个XML文件中定义的

<?xml version="1.0" encoding="utf-8"?>
<gl:GLOBALLISTS xmlns:gl="http://schemas.microsoft.com/VisualStudio/2005/workitemtracking/globallists">
  <GLOBALLIST name="MyListOfVersions">
      <LISTITEM value="1.2107.0.0" />
      <LISTITEM value="1.2201.0.0" />
      <LISTITEM value="1.1.0.2202" />
      <LISTITEM value="1.1.0.2203" />
      <LISTITEM value="1.1.0.2204" />
  </GLOBALLIST>
</gl:GLOBALLISTS>

and imported using a command like 然后使用类似的命令导入

witadmin importgloballist /collection:http://your_tfs_server:8080/tfs/DefaultCollection /f:MyListOfVersionsGlobalLists.xml

Now it is easy to edit this list without changing the definition. 现在,无需更改定义即可轻松编辑此列表。 You can re-run the same command altering the file's content, or, if you prefer pure Powershell code, look at Adding to a GlobalList 您可以重新运行同一命令来更改文件的内容,或者,如果您更喜欢纯Powershell代码,请查看添加到GlobalList。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM