简体   繁体   中英

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. Just make sure you specify the correct team project to QueryBuildDefinitions(String).

  2. .Net API can only get XAML build definitions. If you use new build definitions, you are not able to get the build definitions from a .net api.

  3. It's suggested use REST API to get Build Definitions. REST API can get both XAML build definitions and new build definitions.

REST API to get a list of build definitions :

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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