true true v = new Dictionary(); string year = DateTime.UtcNow.Year.ToString(); v.Add("SWITCH_VERSION_YEAR", year); foreach (Match m in Regex.Matches(ConfigureAC, pattern)) { string value = m.Groups[2].Value.Trim(); if (value.Contains("-")) { string[] tokens = value.Split('-'); value = tokens[0]; } var name = m.Groups[1].Value.Trim(); value = value.Trim(); if (name.StartsWith("SWITCH_VERSION_REVISION")) { if (string.IsNullOrWhiteSpace(value)) { value = revision; } if (name != "SWITCH_VERSION_REVISION_HUMAN") { value = "~" + value; if (commit_count > 0) { value = "-dev-"+ commits + value; } else { value = "-release" + value; } } } v.Add(name, value); Log.LogMessage(MessageImportance.High, name + " = '" + value + "'"); } //--------------------------------------------------------- Log.LogMessage(MessageImportance.High, "Generating switch_version.h"); TemplatePath = basedir + @"src\include\switch_version.h.template"; DestinationPath = basedir + @"src\include\switch_version.h"; string template = File.ReadAllText(TemplatePath); foreach (var version_bit in v) { template = template.Replace("@" + version_bit.Key + "@", version_bit.Value); } File.WriteAllText(DestinationPath, template); //--------------------------------------------------------- Log.LogMessage(MessageImportance.High, "Generating switch_version.inc"); TemplatePath = @"$(ProjectDir)\switch_version.inc.template"; DestinationPath = @"$(ProjectDir)\switch_version.inc"; template = File.ReadAllText(TemplatePath); foreach (var version_bit in v) { template = template.Replace("@" + version_bit.Key + "@", version_bit.Value); } File.WriteAllText(DestinationPath, template); //--------------------------------------------------------- return true; } } ]]>