Пример #1
0
        static void Main(string[] args)
        {
            string action = null;
            string rootFolder = null;
            string product = null;
            string buildNumber = null;
            string edition = "BTE";
            string basePath = null;
            string applicationFileName = null;
            bool showHelp = false;

            var param = new OptionSet
            {
                {"a|Action=", "the action 'UpdateAssemblies' or 'FileComponents'",
                    v =>
                    {
                        if (new List<string>{"updateassemblies", "filecomponents"}.Contains(v.ToLower()))
                            action = v.ToLower();
                        else
                            throw new ArgumentException("unknown action");
                        DebugMessage("Action: {0}", action);
                    }},
                {"r|RootFolder=", "all items and subfolders are scanned for AssemblyInfo.cs",
                    v =>
                    {
                        if (Directory.Exists(v))
                            rootFolder = v;
                        else
                            throw new ArgumentException("RootFolder missing");
                        DebugMessage("RootFoler: {0}", rootFolder);
                    }},
                {"p|Product=", "name of the product (ex. 'Pathway')", v => { product = v; DebugMessage("Product: {0}", product); }},
                {"n|BuildNumber=", "the build number (ex. 1.13.4.4657)",
                    v =>
                    {
                        if (Exp.Match(v).Success)
                            buildNumber = v;
                        else
                            throw new ArgumentException("build number format error");
                        DebugMessage("BuildNumber: {0}", buildNumber);
                    }},
                {"e|Edition=", "the edition, either 'BTE' or 'SE'",
                    v =>
                    {
                        if (new List<string>{"BTE", "SE"}.Contains(v))
                            edition = v;
                        else
                            throw new ArgumentException("unknown edition, must be BTE or SE");
                        DebugMessage("Edition: {0}", edition);
                    }},
                {"b|BasePath=", "location of FileLibrary.xml",
                    v =>
                    {
                        if (File.Exists(Path.Combine(v, "FileLibrary.xml")))
                            basePath = v;
                        else
                            throw new ArgumentException("FileLibrary.xml not present at BasePath");
                        DebugMessage("BasePath: {0}", basePath);
                    }},
                {"f|ApplicationFileName=", "name of the application file", v => { applicationFileName = v; DebugMessage("ApplicationFileName: {0}", applicationFileName); }},
                { "h|Help",  "show this message and exit", 
                   v => showHelp = v != null },
                { "v", "increase debug message verbosity",
                   v => { if (v != null) ++_verbosity; } },


            };
            try
            {
                var extra = param.Parse(args);
                if (extra.Count != 0 || showHelp)
                {
                    ShowHelp(param);
                    return;
                }
            }
            catch (OptionException e)
            {
                Console.Write("BuildStep: ");
                Console.WriteLine(e.Message);
                Console.WriteLine("Try `BuildStep --Help' for more information.");
                return;
            }

            switch (action)
            {
                case "updateassemblies":
                    var act = new UpdateAssemblies{BuildNumber = buildNumber, Product = product, RootFolder = rootFolder, Edition = edition};
                    if (!act.Execute())
                        throw new ApplicationException("UpdateAssemblies Failed.");
                    break;
                case "filecomponents":
                    var componentsAct = new FileComponents{ApplicationFileName = applicationFileName, BasePath = basePath};
                    if (!componentsAct.Execute())
                        throw new ApplicationException("FileComponents action failed.");
                    break;
                default:
                    ShowHelp(param);
                    break;
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            string action              = null;
            string rootFolder          = null;
            string product             = null;
            string buildNumber         = null;
            string edition             = "BTE";
            string basePath            = null;
            string applicationFileName = null;
            bool   showHelp            = false;

            var param = new OptionSet
            {
                { "a|Action=", "the action 'UpdateAssemblies' or 'FileComponents'",
                  v =>
                  {
                      if (new List <string> {
                            "updateassemblies", "filecomponents"
                        }.Contains(v.ToLower()))
                      {
                          action = v.ToLower();
                      }
                      else
                      {
                          throw new ArgumentException("unknown action");
                      }
                      DebugMessage("Action: {0}", action);
                  } },
                { "r|RootFolder=", "all items and subfolders are scanned for AssemblyInfo.cs",
                  v =>
                  {
                      if (Directory.Exists(v))
                      {
                          rootFolder = v;
                      }
                      else
                      {
                          throw new ArgumentException("RootFolder missing");
                      }
                      DebugMessage("RootFoler: {0}", rootFolder);
                  } },
                { "p|Product=", "name of the product (ex. 'Pathway')", v => { product = v; DebugMessage("Product: {0}", product); } },
                { "n|BuildNumber=", "the build number (ex. 1.13.4.4657)",
                  v =>
                  {
                      if (Exp.Match(v).Success)
                      {
                          buildNumber = v;
                      }
                      else
                      {
                          throw new ArgumentException("build number format error");
                      }
                      DebugMessage("BuildNumber: {0}", buildNumber);
                  } },
                { "e|Edition=", "the edition, either 'BTE' or 'SE'",
                  v =>
                  {
                      if (new List <string> {
                            "BTE", "SE"
                        }.Contains(v))
                      {
                          edition = v;
                      }
                      else
                      {
                          throw new ArgumentException("unknown edition, must be BTE or SE");
                      }
                      DebugMessage("Edition: {0}", edition);
                  } },
                { "b|BasePath=", "location of FileLibrary.xml",
                  v =>
                  {
                      if (File.Exists(Path.Combine(v, "FileLibrary.xml")))
                      {
                          basePath = v;
                      }
                      else
                      {
                          throw new ArgumentException("FileLibrary.xml not present at BasePath");
                      }
                      DebugMessage("BasePath: {0}", basePath);
                  } },
                { "f|ApplicationFileName=", "name of the application file", v => { applicationFileName = v; DebugMessage("ApplicationFileName: {0}", applicationFileName); } },
                { "h|Help", "show this message and exit",
                  v => showHelp = v != null },
                { "v", "increase debug message verbosity",
                  v => { if (v != null)
                         {
                             ++_verbosity;
                         }
                  } },
            };

            try
            {
                var extra = param.Parse(args);
                if (extra.Count != 0 || showHelp)
                {
                    ShowHelp(param);
                    return;
                }
            }
            catch (OptionException e)
            {
                Console.Write("BuildStep: ");
                Console.WriteLine(e.Message);
                Console.WriteLine("Try `BuildStep --Help' for more information.");
                return;
            }

            switch (action)
            {
            case "updateassemblies":
                var act = new UpdateAssemblies {
                    BuildNumber = buildNumber, Product = product, RootFolder = rootFolder, Edition = edition
                };
                if (!act.Execute())
                {
                    throw new ApplicationException("UpdateAssemblies Failed.");
                }
                break;

            case "filecomponents":
                var componentsAct = new FileComponents {
                    ApplicationFileName = applicationFileName, BasePath = basePath, Product = product
                };
                if (!componentsAct.Execute())
                {
                    throw new ApplicationException("FileComponents action failed.");
                }
                break;

            default:
                ShowHelp(param);
                break;
            }
        }
Пример #3
0
        static void Main(string[] args)
        {
            string action              = null;
            string rootFolder          = null;
            string releaseFolder       = "../output/Release";
            string basePath            = null;
            string applicationFileName = null;
            bool   showHelp            = false;

            var param = new OptionSet
            {
                { "a|Action=", "the action 'UpdateAssemblies' or 'FileComponents'",
                  v =>
                  {
                      if (new List <string> {
                            "filecomponents"
                        }.Contains(v.ToLower()))
                      {
                          action = v.ToLower();
                      }
                      else
                      {
                          throw new ArgumentException("unknown action");
                      }
                      DebugMessage("Action: {0}", action);
                  } },
                { "r|RootFolder=", "all items and subfolders are scanned for AssemblyInfo.cs",
                  v =>
                  {
                      if (Directory.Exists(v))
                      {
                          rootFolder = v;
                      }
                      else
                      {
                          throw new ArgumentException("RootFolder missing");
                      }
                      DebugMessage("RootFoler: {0}", rootFolder);
                  } },
                { "o|ReleaseFolder=", "path to output release files (optionally relative to base path)",
                  v =>
                  {
                      if (!string.IsNullOrEmpty(basePath) && Directory.Exists(Path.Combine(basePath, v)))
                      {
                          releaseFolder = v;
                      }
                      else if (Directory.Exists(v))
                      {
                          releaseFolder = v;
                      }
                      else
                      {
                          throw new ArgumentException("ReleaseFolder missing");
                      }
                      DebugMessage("ReleaseFoler: {0}", releaseFolder);
                  } },
                { "b|BasePath=", "location of FileLibrary.xml",
                  v =>
                  {
                      if (File.Exists(Path.Combine(v, "FileLibrary.xml")))
                      {
                          basePath = v;
                      }
                      else
                      {
                          throw new ArgumentException("FileLibrary.xml not present at BasePath");
                      }
                      DebugMessage("BasePath: {0}", basePath);
                  } },
                { "f|ApplicationFileName=", "name of the application file", v => { applicationFileName = v; DebugMessage("ApplicationFileName: {0}", applicationFileName); } },
                { "h|Help", "show this message and exit",
                  v => showHelp = v != null },
                { "v", "increase debug message verbosity",
                  v => { if (v != null)
                         {
                             ++_verbosity;
                         }
                  } },
            };

            try
            {
                var extra = param.Parse(args);
                if (extra.Count != 0 || showHelp)
                {
                    ShowHelp(param);
                    return;
                }
            }
            catch (OptionException e)
            {
                Console.Write("BuildStep: ");
                Console.WriteLine(e.Message);
                Console.WriteLine("Try `BuildStep --Help' for more information.");
                return;
            }

            switch (action)
            {
            case "filecomponents":
                var componentsAct = new FileComponents {
                    ApplicationFileName = applicationFileName, BasePath = basePath, ReleaseFolder = releaseFolder
                };
                if (!componentsAct.Execute())
                {
                    throw new ApplicationException("FileComponents action failed.");
                }
                break;

            default:
                ShowHelp(param);
                break;
            }
        }