Beispiel #1
0
        static void Main(string[] args)
        {
            if (args.Length >= 2)
            {
                GetBuildList();
                string file = args[0];
                string name = args[1];

                bool ignoreFile     = false;
                bool ignoreInternal = false;

                if (args.Length >= 3)
                {
                    bool.TryParse(args[2], out ignoreFile);
                }
                if (args.Length >= 4)
                {
                    bool.TryParse(args[3], out ignoreInternal);
                }

                var fileVersionRx = new Regex(@"\[assembly: AssemblyFileVersion\((.*)\)\]");
                var versionRx     = new Regex(@"\[assembly: AssemblyVersion\((.*)\)\]");

                string buildNum = GetBuildNumber(name);

                if (File.Exists(file))
                {
                    if (!ignoreFile)
                    {
                        File.WriteAllLines(file,
                                           File.ReadAllLines(file).Select(s =>
                                                                          fileVersionRx.Replace(s, GetVersion(true, buildNum))
                                                                          )
                                           );
                    }
                    if (!ignoreInternal)
                    {
                        File.WriteAllLines(file,
                                           File.ReadAllLines(file).Select(s =>
                                                                          versionRx.Replace(s, GetVersion(false, buildNum))
                                                                          )
                                           );
                    }
                }
                SaveBuildList();
                BuildList = null;
            }
        }
Beispiel #2
0
        static void GetBuildList()
        {
            string exeLocation   = System.Reflection.Assembly.GetEntryAssembly().Location;
            string exeDirectory  = Path.GetDirectoryName(exeLocation);
            string buildListFile = Path.Combine(exeDirectory, "build_list.json");

            if (!File.Exists(buildListFile))
            {
                File.Create(buildListFile).Close();
            }

            string data = File.ReadAllText(buildListFile);

            BuildList = Newtonsoft.Json.JsonConvert.DeserializeObject <BuildList>(data);
            if (BuildList == null)
            {
                BuildList = new BuildList();
            }
        }