示例#1
0
        public static int Main(string[] args)
        {
            if (args.Length == 0)
            {
                ShowUsage();
                return(0);
            }

            Uri           connectionUrl;
            string        area, resource;
            DirectoryInfo outputPath;

            try
            {
                CheckArguments(args, out connectionUrl, out area, out resource, out outputPath);
            }
            catch (ArgumentException ex)
            {
                Console.WriteLine(ex.Message);

                ShowUsage();

                return(-1);
            }

#if NETCOREAPP
            string checkPat = Environment.GetEnvironmentVariable(PAT_ENV_VAR);
            if (string.IsNullOrEmpty(checkPat))
            {
                Console.WriteLine("On .NET Core, you must set an environment variable " + PAT_ENV_VAR + " with a personal access token.");
                return(-1);
            }
#endif


            try
            {
                ClientSampleUtils.RunClientSampleMethods(connectionUrl, null, area: area, resource: resource, outputPath: outputPath);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Failed to run the sample: " + ex.Message);
                return(1);
            }

            return(0);
        }
示例#2
0
        public static int Main(string[] args)
        {
            if (args.Length == 0)
            {
                ShowUsage();
                return(0);
            }

            Uri           connectionUrl;
            string        area, resource;
            DirectoryInfo outputPath;

            try
            {
                CheckArguments(args, out connectionUrl, out area, out resource, out outputPath);
            }
            catch (ArgumentException ex)
            {
                Console.WriteLine(ex.Message);

                ShowUsage();

                return(-1);
            }

            try
            {
                ClientSampleUtils.RunClientSampleMethods(connectionUrl, null, area: area, resource: resource, outputPath: outputPath);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Failed to run the sample: " + ex.Message);
                return(1);
            }

            return(0);
        }
示例#3
0
        private static void ShowUsage()
        {
            Console.WriteLine("Runs the client samples on a Team Services account or Team Foundation Server instance.");
            Console.WriteLine("");
            Console.WriteLine("!!WARNING!! Some samples are destructive. Always run on a test account or collection.");
            Console.WriteLine("");
            Console.WriteLine("Required arguments:");
            Console.WriteLine("");
            Console.WriteLine("  /url:{value}         URL of the account/collection to run the samples against.");
            Console.WriteLine("  /area:{value}        API area to run the client samples for. Use * to include all areas.");
            Console.WriteLine("  /resource:{value}    API resource to run the client samples for. Use * to include all resources.");
            Console.WriteLine("");
            Console.WriteLine("Optional arguments:");
            Console.WriteLine("  /outputPath:{value}  Path for saving HTTP request/response files. If not specified, files are not generated.");
            Console.WriteLine("");
            Console.WriteLine("Examples:");
            Console.WriteLine("");
            Console.WriteLine("  Microsoft.Azure.DevOps.ClientSamples.exe /url:https://dev.azure.com/fabrikam /area:* /resource:*");
            Console.WriteLine("  Microsoft.Azure.DevOps.ClientSamples.exe /url:https://dev.azure.com/fabrikam /area:* /resource:* /outputPath:\"c:\\temp\\output results\"");
            Console.WriteLine("  Microsoft.Azure.DevOps.ClientSamples.exe /url:https://dev.azure.com/fabrikam /area:wit /resource:*");
            Console.WriteLine("  Microsoft.Azure.DevOps.ClientSamples.exe /url:https://dev.azure.com/fabrikam /area:git /resource:pullrequests /outputPath:.\\output");
            Console.WriteLine("");

            Dictionary <ClientSample, IEnumerable <RunnableClientSampleMethod> > runnableMethodsBySample = ClientSampleUtils.GetRunnableClientSampleMethods();

            HashSet <string> areas = new HashSet <string>(StringComparer.InvariantCultureIgnoreCase);

            foreach (var kvp in runnableMethodsBySample)
            {
                foreach (var rcsm in kvp.Value)
                {
                    areas.Add(rcsm.Area.ToLower());
                }
            }

            Console.WriteLine("Available areas: " + String.Join(",", areas.ToArray <string>()));
        }