Example #1
0
        static void Main(string[] args)
        {
            var commandLine = new CommandLineArguments(args);
            try
            {
                ValidateCommandLine(commandLine);

                Version version = new Version(
                    commandLine.Major,
                    commandLine.Minor,
                    commandLine.Build.Value,
                    commandLine.Revision.HasValue ? commandLine.Revision.Value : 0);

                UpdateCSVersionInfo(commandLine.VersionCsPath, version);
                if (!String.IsNullOrEmpty(commandLine.AndroidManifestPath))
                {
                    UpdateAndroidVersionInfo(commandLine.AndroidManifestPath, version);
                }
                if (!String.IsNullOrEmpty(commandLine.TouchPListPath))
                {
                    UpdateTouchVersionInfo(commandLine.TouchPListPath, version);
                }

            }
            catch (Exception e)
            {
                WriteHelp(commandLine, "An unexpected error was encountered:" + e.Message);
            }
        }
Example #2
0
 private static void ValidateCommandLine(CommandLineArguments commandLine)
 {
     if (commandLine.ShowHelp)
     {
         WriteHelp(commandLine);
         return;
     }
     var errors = new System.Text.StringBuilder();
     if (commandLine.Major < 0)
     {
         errors.AppendLine("You must supply a positive major version number.");
     }
     if (commandLine.Minor < 0)
     {
         errors.AppendLine("You must supply a positive minor version number.");
     }
     if (!commandLine.Build.HasValue)
     {
         errors.AppendLine("You must supply a numeric build number.");
     }
     if (String.IsNullOrEmpty(commandLine.VersionCsPath) || !IsValidCSharpVersionFile(commandLine.VersionCsPath))
     {
         errors.AppendLine("You must supply valid path to a writable C# file containing assembly version information.");
     }
     if (!String.IsNullOrEmpty(commandLine.AndroidManifestPath) && !IsValidAndroidManifest(commandLine.AndroidManifestPath))
     {
         errors.AppendLine("You must supply valid path to a writable android manifest file.");
     }
     if (!String.IsNullOrEmpty(commandLine.TouchPListPath) && !IsValidTouchPList(commandLine.TouchPListPath))
     {
         errors.AppendLine("You must supply valid path to a writable plist file containing version information.");
     }
     if (errors.Length > 0)
     {
         WriteHelp(commandLine, "Invalid command line:\n" + errors.ToString());
     }
 }
Example #3
0
 private static void WriteHelp(CommandLineArguments commandLine, String message = null)
 {
     if (!String.IsNullOrEmpty(message))
     {
         Console.WriteLine(message);
     }
     commandLine.WriteHelp(Console.Out);
 }
Example #4
0
        static void Main(string[] args)
        {
            commandLine = new CommandLineArguments(args);

            if (!MainViewModel.Current.Silent)
            {
                Console.WriteLine("");
                Console.WriteLine($"UpdateVersionInfo - V{MainViewModel.Current.UpdateVersionInfoVersion}");
                Console.WriteLine("");
            }
            ;

            if (ValidateCommandLine(commandLine))
            {
                if (MainViewModel.Current.Info)
                {
                    string formatStr = (MainViewModel.Current.Verbose
                  ? "{0,6} {1,-10} - {2}"
                  : "{0,6} {1,-10}");


                    foreach (var f in MainViewModel.Current.Files)
                    {
                        if (System.IO.File.Exists(f.Target))
                        {
                            switch (f.Name)
                            {
                            case "vi":
                                _VI_Helper.GetVersion(f.Target);

                                if (!MainViewModel.Current.Silent)
                                {
                                    Console.WriteLine(formatStr, "", _VI_Helper.LastMessage, f.Target);
                                }
                                ;
                                break;

                            case "UWP":
                                UWPHelper.GetVersion(f.Target);

                                if (!MainViewModel.Current.Silent)
                                {
                                    Console.WriteLine(formatStr, "UWP", UWPHelper.LastMessage, f.Target);
                                }
                                ;
                                break;

                            case "Droid":
                                DroidHelper.GetVersion(f.Target);

                                if (!MainViewModel.Current.Silent)
                                {
                                    Console.WriteLine(formatStr, "Droid", DroidHelper.LastMessage, f.Target);
                                }
                                ;
                                break;

                            case "WPF":
                                break;

                            case "iOS":
                                iOSHelper.GetVersion(f.Target);

                                if (!MainViewModel.Current.Silent)
                                {
                                    Console.WriteLine(formatStr, "iOS", iOSHelper.LastMessage, f.Target);
                                }
                                ;
                                break;

                            case "MacOS":
                                break;

                            case "Nuget":
                                NugetHelper.GetVersion(f.Target);

                                if (!MainViewModel.Current.Silent)
                                {
                                    Console.WriteLine(formatStr, "Nuget", NugetHelper.LastMessage, f.Target);
                                }
                                ;
                                break;

                            case "Setup":
                                DeployProjectHelper.GetVersion(f.Target);

                                if (!MainViewModel.Current.Silent)
                                {
                                    Console.WriteLine(formatStr, "Setup", DeployProjectHelper.LastMessage, f.Target);
                                }
                                ;
                                break;
                            }
                            ;
                        }
                        ;
                    }
                    ;
                }
                else
                {
                    string formatStr = (MainViewModel.Current.Verbose
                  ? "{0,6} {1,-24} - {2}"
                  : "{0,6} {1,-24}");


                    try
                    {
                        Version version = new Version(
                            MainViewModel.Current.Major,
                            MainViewModel.Current.Minor,
                            MainViewModel.Current.Build.Value,
                            MainViewModel.Current.Revision.HasValue ? MainViewModel.Current.Revision.Value : 0);

                        foreach (var f in MainViewModel.Current.Files)
                        {
                            if (System.IO.File.Exists(f.Target))
                            {
                                switch (f.Name)
                                {
                                case "vi":
                                    version = _VI_Helper.Update(f.Target);
                                    if (!MainViewModel.Current.Silent)
                                    {
                                        Console.WriteLine(formatStr, "", _VI_Helper.LastMessage, f.Target);
                                    }
                                    ;
                                    break;

                                case "UWP":
                                    UWPHelper.Update(f.Target, version);
                                    if (!MainViewModel.Current.Silent)
                                    {
                                        Console.WriteLine(formatStr, "UWP", UWPHelper.LastMessage, f.Target);
                                    }
                                    ;
                                    break;

                                case "Droid":
                                    DroidHelper.Update(f.Target, version);

                                    if (!MainViewModel.Current.Silent)
                                    {
                                        Console.WriteLine(formatStr, "Droid", DroidHelper.LastMessage, f.Target);
                                    }
                                    ;
                                    break;

                                case "WPF":
                                    break;

                                case "iOS":
                                    iOSHelper.Update(f.Target, version);

                                    if (!MainViewModel.Current.Silent)
                                    {
                                        Console.WriteLine(formatStr, "iOS", iOSHelper.LastMessage, f.Target);
                                    }
                                    ;
                                    break;

                                case "MacOS":
                                    break;

                                case "Nuget":
                                    NugetHelper.Update(f.Target, version);

                                    if (!MainViewModel.Current.Silent)
                                    {
                                        Console.WriteLine(formatStr, "Nuget", NugetHelper.LastMessage, f.Target);
                                    }
                                    ;
                                    break;

                                case "Setup":
                                    DeployProjectHelper.Update(f.Target, version);

                                    if (!MainViewModel.Current.Silent)
                                    {
                                        Console.WriteLine(formatStr, "Setup", DeployProjectHelper.LastMessage, f.Target);
                                    }
                                    ;
                                    break;
                                }
                                ;
                            }
                            ;
                        }
                        ;
                    }
                    catch (Exception e)
                    {
                        WriteHelp(commandLine, "An unexpected error was encountered:" + e.Message);
                    }
                };
            }
            ;

            if (Debugger.IsAttached)
            {
                Console.Read();
            }
            ;
        }