Sql 使用特定自定义参数查询生成定义

Sql 使用特定自定义参数查询生成定义,sql,tfs,build-definition,Sql,Tfs,Build Definition,我需要一些关于SQL查询的帮助,该查询将返回包含特定自定义参数的生成定义列表 我遇到了这个查询,但我在想如何进一步深入时遇到了一些困难 以下是此查询返回的XML示例: <Dictionary x:TypeArguments="x:String, x:Object" xmlns="clr-namespace:System.Collections.Generic;assembly=mscorlib" xmlns:mtbwa="clr-namespace:Microsoft.TeamFoun

我需要一些关于SQL查询的帮助,该查询将返回包含特定自定义参数的生成定义列表

我遇到了这个查询,但我在想如何进一步深入时遇到了一些困难

以下是此查询返回的XML示例:

<Dictionary x:TypeArguments="x:String, x:Object" xmlns="clr-namespace:System.Collections.Generic;assembly=mscorlib" xmlns:mtbwa="clr-namespace:Microsoft.TeamFoundation.Build.Workflow.Activities;assembly=Microsoft.TeamFoundation.Build.Workflow" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <mtbwa:BuildSettings x:Key="BuildSettings" ProjectsToBuild="$/ACME/Dev/v1.0.0/Source/ACME/ACME.sln">
    <mtbwa:BuildSettings.PlatformConfigurations>
      <mtbwa:PlatformConfigurationList Capacity="1">
        <mtbwa:PlatformConfiguration Configuration="ACMS Website" Platform="Any CPU" />
      </mtbwa:PlatformConfigurationList>
     </mtbwa:BuildSettings.PlatformConfigurations>
   </mtbwa:BuildSettings>
   <mtbwa:TestSpecList x:Key="TestSpecs" Capacity="1">
     <mtbwa:TestAssemblySpec MSTestCommandLineArgs="{x:Null}" TestSettingsFileName="{x:Null}" AssemblyFileSpec="**\*test*.dll" CategoryFilter="!CodedUITest" />
   </mtbwa:TestSpecList>
   <mtbwa:SourceAndSymbolServerSettings x:Key="SourceAndSymbolServerSettings" SymbolStorePath="\\ACME.com\dfs\USA\AppDev\TeamBuild\Symbols" />
   <mtbwa:AgentSettings x:Key="AgentSettings" MaxWaitTime="04:00:00" Name="*" Tags="" />
   <x:Boolean x:Key="SCA">False</x:Boolean>
   <x:String x:Key="SSCProjectVersion">ACME v1.0.0</x:String>
</Dictionary>
警告 不建议直接查询TFS操作数据存储,并且这些字段的内容可能会在不同版本甚至修补程序之间更改,恕不另行通知。官方的方法是使用客户机对象模型。您意外对数据所做的任何更改都会使服务器处于不受支持的状态

TFS客户机对象模型提供了一个相对简单的模型。从那里,您可以使用标准的.NETXML类(Linq-2-XML或标准的XPathNavigator)快速获取所需的信息。您要查找的参数甚至可能是

这将产生以下代码(由OP提供):


警告:不建议直接查询TFS操作数据存储,并且这些字段的内容可能会在不同版本甚至修补程序之间更改,恕不另行通知。官方的方法是使用客户机对象模型。在我看来,使用C#更容易深入到XML中。我发现了一个很好的例子,说明了我需要使用API。比我预想的容易多了。谢谢如果你想把它贴出来作为答案,我会这样做。我已经编辑了你的标题。请参阅“”,其中的共识是“不,他们不应该”。
<Dictionary x:TypeArguments="x:String, x:Object" xmlns="clr-namespace:System.Collections.Generic;assembly=mscorlib" xmlns:mtbwa="clr-namespace:Microsoft.TeamFoundation.Build.Workflow.Activities;assembly=Microsoft.TeamFoundation.Build.Workflow" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <mtbwa:BuildSettings x:Key="BuildSettings" ProjectsToBuild="$/ACME/Dev/v1.0.0/Source/ACME/ACME.sln">
    <mtbwa:BuildSettings.PlatformConfigurations>
      <mtbwa:PlatformConfigurationList Capacity="1">
        <mtbwa:PlatformConfiguration Configuration="ACMS Website" Platform="Any CPU" />
      </mtbwa:PlatformConfigurationList>
     </mtbwa:BuildSettings.PlatformConfigurations>
   </mtbwa:BuildSettings>
   <mtbwa:TestSpecList x:Key="TestSpecs" Capacity="1">
     <mtbwa:TestAssemblySpec MSTestCommandLineArgs="{x:Null}" TestSettingsFileName="{x:Null}" AssemblyFileSpec="**\*test*.dll" CategoryFilter="!CodedUITest" />
   </mtbwa:TestSpecList>
   <mtbwa:SourceAndSymbolServerSettings x:Key="SourceAndSymbolServerSettings" SymbolStorePath="\\ACME.com\dfs\USA\AppDev\TeamBuild\Symbols" />
   <mtbwa:AgentSettings x:Key="AgentSettings" MaxWaitTime="04:00:00" Name="*" Tags="" />
   <x:Boolean x:Key="SCA">False</x:Boolean>
   <x:String x:Key="SSCProjectVersion">ACME v1.0.0</x:String>
</Dictionary>
TfsTeamProjectCollection server = new TfsTeamProjectCollection(new Uri("http://acmetfs:8080/tfs"));
server.EnsureAuthenticated();
IBuildServer build = (IBuildServer)server.GetService(typeof(IBuildServer));
IBuildDefinition buildDefinition = build.GetBuildDefinition("ACME", "ACME_v1.0.0");

object argumentValue;
if (WorkflowHelpers.DeserializeProcessParameters(buildDefinition.ProcessParameters).TryGetValue("SCA", out argumentValue))
{
  Console.WriteLine(argumentValue);
}        
TfsTeamProjectCollection server = new TfsTeamProjectCollection(new Uri("http://acmetfs:8080/tfs"));
server.EnsureAuthenticated();
IBuildServer build = (IBuildServer)server.GetService(typeof(IBuildServer));
IBuildDefinition buildDefinition = build.GetBuildDefinition("ACME", "ACME_v1.0.0");

object argumentValue;
if (WorkflowHelpers.DeserializeProcessParameters(buildDefinition.ProcessParameters).TryGetValue("SCA", out argumentValue))
{
  Console.WriteLine(argumentValue);
}