MCPcopy Create free account
hub / github.com/M2Team/NanaBox / Program

Class Program

NanaBox.RefreshPackageVersion/Program.cs:7–174  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5namespace NanaBox.RefreshPackageVersion
6{
7 internal class Program
8 {
9 static (int Major, int Minor) Version = (1, 6);
10 static string BuildStartDay = "2022-04-01";
11
12 static string GenerateVersionString()
13 {
14 return string.Format(
15 "{0}.{1}.{2}.0",
16 Version.Major,
17 Version.Minor,
18 DateTime.Today.Subtract(DateTime.Parse(BuildStartDay)).TotalDays);
19 }
20
21 static string RepositoryRoot = GitRepository.GetRootPath();
22
23 static void RefreshAppxManifestVersion()
24 {
25 string FilePath = string.Format(
26 @"{0}\NanaBoxPackage\Package.appxmanifest",
27 RepositoryRoot);
28
29 XmlDocument Document = new XmlDocument();
30 Document.PreserveWhitespace = true;
31 Document.Load(FilePath);
32
33 XmlNode? PackageNode = Document["Package"];
34 if (PackageNode != null)
35 {
36 XmlNode? IdentityNode = PackageNode["Identity"];
37 if (IdentityNode != null)
38 {
39 XmlAttribute? VersionAttribute =
40 IdentityNode.Attributes["Version"];
41 if (VersionAttribute != null)
42 {
43 FileUtilities.SaveTextToFileAsUtf8Bom(
44 FilePath,
45 File.ReadAllText(FilePath).Replace(
46 VersionAttribute.Value,
47 GenerateVersionString()));
48 }
49 }
50 }
51 }
52
53 static void ReplaceFileContentViaStringList(
54 string FilePath,
55 List<string> FromList,
56 List<string> ToList)
57 {
58 if (FromList.Count != ToList.Count)
59 {
60 throw new ArgumentOutOfRangeException();
61 }
62
63 string Content = File.ReadAllText(FilePath, Encoding.UTF8);
64

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected