예제 #1
0
        static string VersionFile(FileInfo outputFile, VersionerOptions options)
        {
            var allLines           = File.ReadAllLines(outputFile.FullName);
            int versionStringIndex = 0;
            int buildDateIndex     = 0;

            for (int i = 0; i < allLines.Length; i++)
            {
                var line = allLines[i];
                if (line.Contains(VersionString))
                {
                    versionStringIndex = i;
                }
                else if (line.Contains(LastBuildDate))
                {
                    buildDateIndex = i;
                }
            }

            string versionString = allLines[versionStringIndex];

            versionString = versionString.Replace(VersionString, string.Empty);
            versionString = versionString.Replace(");", string.Empty);
            var versionParts = versionString.Split(new string[] { "," }, System.StringSplitOptions.RemoveEmptyEntries);

            uint majorVal    = Convert.ToUInt32(versionParts[0]);
            uint minorVal    = Convert.ToUInt32(versionParts[1]);
            uint buildVal    = Convert.ToUInt32(versionParts[2]);
            uint revisionVal = Convert.ToUInt32(versionParts[3]);


            int curRevision = TryGetSVNRevision(outputFile.Directory.FullName);

            if (curRevision > 0 && curRevision != revisionVal)
            {
                buildVal    = 0;
                revisionVal = (uint)curRevision;
            }
            ++buildVal;

            //get result
            var resultVersionString = string.Join(",", majorVal, minorVal, buildVal, revisionVal);

            allLines[versionStringIndex] = string.Format("\t{0}{1});", VersionString, resultVersionString);


            string dataString = DateTime.Now.ToString("u");

            dataString = dataString.Remove(dataString.Length - 1); //remove last char
            allLines[buildDateIndex] = string.Format("\t{0}\"{1}\";", LastBuildDate, dataString);

            using (StreamWriter sw = new StreamWriter(outputFile.FullName))
            {
                foreach (var allLine in allLines)
                {
                    sw.WriteLine(allLine);
                }
            }


            return(resultVersionString);
        }
예제 #2
0
파일: Program.cs 프로젝트: whztt07/Medusa
        static string VersionFile(FileInfo outputFile, VersionerOptions options)
        {
            var allLines = File.ReadAllLines(outputFile.FullName);
            int versionStringIndex = 0;
            int buildDateIndex = 0;

            for (int i = 0; i < allLines.Length; i++)
            {
                var line = allLines[i];
                if (line.Contains(VersionString))
                {
                    versionStringIndex = i;
                }
                else if (line.Contains(LastBuildDate))
                {
                    buildDateIndex = i;
                }
            }

            string versionString = allLines[versionStringIndex];
            versionString = versionString.Replace(VersionString, string.Empty);
            versionString = versionString.Replace(");", string.Empty);
            var versionParts = versionString.Split(new string[] { "," }, System.StringSplitOptions.RemoveEmptyEntries);

            uint majorVal = Convert.ToUInt32(versionParts[0]);
            uint minorVal = Convert.ToUInt32(versionParts[1]);
            uint buildVal = Convert.ToUInt32(versionParts[2]);
            uint revisionVal = Convert.ToUInt32(versionParts[3]);

            int curRevision = TryGetSVNRevision(outputFile.Directory.FullName);
            if (curRevision>0&&curRevision != revisionVal)
            {
                buildVal = 0;
                revisionVal = (uint)curRevision;
            }
            ++buildVal;

            //get result
            var resultVersionString = string.Join(",", majorVal, minorVal, buildVal, revisionVal);
            allLines[versionStringIndex] = string.Format("\t{0}{1});", VersionString, resultVersionString);

            string dataString = DateTime.Now.ToString("u");
            dataString = dataString.Remove(dataString.Length - 1); //remove last char
            allLines[buildDateIndex] = string.Format("\t{0}\"{1}\";", LastBuildDate, dataString);

            using (StreamWriter sw = new StreamWriter(outputFile.FullName))
            {
                foreach (var allLine in allLines)
                {
                    sw.WriteLine(allLine);
                }
            }

            return resultVersionString;
        }