[UpdateAssemblyInfo] Update General/Version in XML translation files

In addition to updating the version (major.minor.maintenance) in
AssemblyInfo.cs.template, also update the XML translation files
when preparing a new release.
This commit is contained in:
Waldi Ravens 2016-03-21 10:09:55 +02:00
parent 57a9bfa480
commit b02f68d6b4
2 changed files with 24 additions and 0 deletions

View File

@ -1,8 +1,10 @@
using System;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Xml;
namespace UpdateAssemblyInfo
{
@ -131,6 +133,22 @@ namespace UpdateAssemblyInfo
}
}
private static void UpdateTranslations(string languagesFolderName, VersionInfo newVersion, VersionInfo oldVersion)
{
var fileNamePattern = string.Format(@"[\{0}\{1}][a-z]{{2,3}}-[A-Za-z-]+\.xml\z", Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
var fileNameRegex = new Regex(fileNamePattern, RegexOptions.Compiled | RegexOptions.ExplicitCapture);
var translation = new XmlDocument { XmlResolver = null };
foreach (var fileName in Directory.EnumerateFiles(languagesFolderName).Where(fn => fileNameRegex.IsMatch(fn)))
{
translation.Load(fileName);
var node = translation.DocumentElement.SelectSingleNode("General/Version") as XmlElement;
if (node != null && node.InnerText.Trim() == oldVersion.ShortVersion)
node.InnerText = newVersion.ShortVersion;
translation.Save(fileName);
}
}
private static void UpdateAssemblyInfo(string templateFileName, VersionInfo newVersion, bool updateTemplateFile = false)
{
var templateText = File.ReadAllText(templateFileName).TrimEnd();
@ -268,6 +286,11 @@ namespace UpdateAssemblyInfo
if (newVersion != currentVersion)
{
Console.WriteLine(" updating version number to " + newVersion.FullVersion);
if (updateTemplateFile) {
var oldVersion = GetTemplateVersion(seTemplateFileName);
var languagesFolderName = Path.Combine(Path.GetDirectoryName(Path.GetDirectoryName(seTemplateFileName)), "Languages");
UpdateTranslations(languagesFolderName, newVersion, oldVersion);
}
UpdateAssemblyInfo(libSeTemplateFileName, newVersion, updateTemplateFile);
UpdateAssemblyInfo(seTemplateFileName, newVersion, updateTemplateFile);
}

View File

@ -36,6 +36,7 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="CommandLineRunner.cs" />