Example #1
0
        public static string PromptIncrementPatchOrBuild(string currentVersion)
        {
            VersionNumber current = new VersionNumber(currentVersion);

            // Prompt for version number
            string version = string.Empty;

            while (string.IsNullOrEmpty(version))
            {
                Console.Write($">> Set version number (current=${currentVersion}): ");
                string input = Console.ReadLine();
                if (string.IsNullOrEmpty(input))
                {
                    Console.WriteLine("Version number cannot be empty");
                }
                else
                {
                    VersionNumber incremented = new VersionNumber(input);

                    if (incremented.Major != current.Major || incremented.Minor != current.Minor)
                    {
                        Console.WriteLine("Cannot increment major or minor version numbers");
                    }
                    else if (incremented.Patch < current.Patch && incremented.Build <= current.Build)
                    {
                        Console.WriteLine("Patch or build version numbers must be incremented");
                    }
                    else
                    {
                        version = input;
                    }
                }
            }

            return(version);
        }
Example #2
0
 public static string Prompt()
 {
     while (true)
     {
         Console.Write(">> Set version number: ");
         string input = Console.ReadLine();
         if (string.IsNullOrEmpty(input))
         {
             Console.WriteLine("Version number cannot be empty");
         }
         else
         {
             try
             {
                 VersionNumber versionNumber = new VersionNumber(input);
                 return(versionNumber.ToString());
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.Message);
             }
         }
     }
 }