Ejemplo n.º 1
0
        private static bool UpdateVersionNumberToCSProj(ICakeContext context, string csprojFilePath, string newVersion)
        {
            var    contents          = FileReadText(context, csprojFilePath);
            string regexPattern      = @"<Version>(.*?)<\/Version>";
            var    rx                = new Regex(regexPattern);
            string xmlizednewVersion = @"<Version>" + newVersion + "</Version>";
            string newcontents       = rx.Replace(contents, xmlizednewVersion);

            FileWriteText(context, csprojFilePath, newcontents);

            LoggingAliases.Information(context, "Update the new product version in the csproj file ",
                                       xmlizednewVersion);

            return(true);
        }
Ejemplo n.º 2
0
        private static string GetProductionVersionFromCSProj(this ICakeContext context, string csprojFilePath)
        {
            var    contents       = FileReadText(context, csprojFilePath);
            string regexPattern   = @"<Version>(.*?)<\/Version>";
            var    rx             = new Regex(regexPattern);
            string productVersion = "";

            if (rx.IsMatch(contents))
            {
                var m = rx.Match(contents);
                productVersion = m.Groups[1].Value;
            }

            LoggingAliases.Information(context, "Following product version found in the csproj file {0}", productVersion);

            return(productVersion);
        }
Ejemplo n.º 3
0
        private static string CreateNewVersion(this ICakeContext context, string productVersion, string buildNumber)
        {
            string[] versionparts = productVersion.Split('.');
            string   newVersion   = "";

            if (versionparts.Length >= 3)
            {
                newVersion = string.Join(".", versionparts[0], versionparts[1], versionparts[2], buildNumber);
                LoggingAliases.Information(context, "Created new version number: {0}", newVersion);
            }
            else
            {
                LoggingAliases.Error(context, "Product version doesn't match three slack, can't form new version number {0} {1}",
                                     productVersion, " format required must be inline of 1.0.0.0 or 1.0.0-aplha");
                throw new InvalidDataException("Product version doesn't match three slack, can't form new version number ");
            }
            return(newVersion);
        }
Ejemplo n.º 4
0
        private static bool IsProductVersionValid(this ICakeContext context, string productVersion)
        {
            string regexPattern = @"\d.\d.\d[.-]\w*";
            var    rx           = new Regex(regexPattern);

            if (rx.IsMatch(productVersion))
            {
                LoggingAliases.Information(context,
                                           "Following product version is **valid** and inline with 1.0.0.0 or 1.0.0-aplha format ",
                                           productVersion);
                return(true);
            }
            else
            {
                LoggingAliases.Error(context, "Product version found in csproj doesn't match required format {0} {1}",
                                     productVersion,
                                     " format required must be inline of 1.0.0.0 or 1.0.0-aplha");
                throw new InvalidDataException("Product version found in csproj doesn't match required format, format required must be inline of 1.0.0.0 or 1.0.0-aplha");
            }
        }