简体   繁体   English

从返回零的vsts构建定义

[英]build definition from vsts returning zero

I have two build definitions in my project but its returning zero build definition. 我的项目中有两个构建定义,但返回零构建定义。 Below is my code get the build definitions. 下面是我的代码,获取构建定义。 Can anyone help? 有人可以帮忙吗?

 // Get a reference to a build service
        IBuildServer buildserver = (IBuildServer)tfs.GetService(typeof(IBuildServer));

        IBuildDefinition[] buildDefinitions = buildserver.QueryBuildDefinitions(project);
        foreach (IBuildDefinition buildDefinition in buildDefinitions)
        {
            string buildDefinitionName = buildDefinition.Name;

            Console.WriteLine(buildDefinitionName);
            Console.WriteLine(buildDefinition.ProcessParameters.ToString());
        }
  1. There is nothing wrong with your code. 您的代码没有错。 I have tested with your code and get XAML build definitions successfully. 我已经对您的代码进行了测试,并成功获取了XAML构建定义。 Just make sure you specify the correct team project to QueryBuildDefinitions(String). 只需确保为QueryBuildDefinitions(String)指定正确的团队项目即可。

  2. .Net API can only get XAML build definitions. .Net API只能获取XAML构建定义。 If you use new build definitions, you are not able to get the build definitions from a .net api. 如果使用新的构建定义,则无法从.net api获取构建定义。

  3. It's suggested use REST API to get Build Definitions. 建议使用REST API来获取构建定义。 REST API can get both XAML build definitions and new build definitions. REST API可以同时获得XAML构建定义和新的构建定义。

REST API to get a list of build definitions : REST API获取构建定义列表

GET https://{instance}/DefaultCollection/{project}/_apis/build/definitions?api-version={version}[&name={string}][&type={string}]

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

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