1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
using System;
using System.IO;
using System.Linq;
namespace Application
{
public class GenVersion
{
public static void Main (string[] args)
{
var dir = args [0];
var lines = File.ReadAllLines (Path.Combine (dir, "..", "..", "..", "..", "version.config"));
var txt = File.ReadAllText (Path.Combine (dir, "BuildVariables.cs.in"));
txt = txt.Replace ("@PACKAGE_VERSION@", GetValue (lines, "Version"));
txt = txt.Replace ("@PACKAGE_VERSION_LABEL@", GetValue (lines, "Label"));
txt = txt.Replace ("@COMPAT_ADDIN_VERSION@", GetValue (lines, "CompatVersion"));
File.WriteAllText (Path.Combine (dir, "BuildVariables.cs"), txt);
}
static string GetValue (string[] lines, string key)
{
var val = lines.First (li => li.StartsWith (key + "="));
return val.Substring (key.Length + 1);
}
}
}
|