diff --git a/src/UpdateAssemblyDescription/App.config b/src/UpdateAssemblyDescription/App.config new file mode 100644 index 000000000..8e1564635 --- /dev/null +++ b/src/UpdateAssemblyDescription/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/UpdateAssemblyDescription/CommandLineRunner.cs b/src/UpdateAssemblyDescription/CommandLineRunner.cs new file mode 100644 index 000000000..f50a3c30a --- /dev/null +++ b/src/UpdateAssemblyDescription/CommandLineRunner.cs @@ -0,0 +1,43 @@ +using System.Diagnostics; + +namespace UpdateAssemblyDescription +{ + public class CommandLineRunner + { + public string Result { get; set; } + + public bool RunCommandAndGetOutput(string command, string arguments, string workingFolder) + { + var p = new Process(); + p.StartInfo.FileName = command; + p.StartInfo.Arguments = arguments; + p.StartInfo.WorkingDirectory = workingFolder; + p.StartInfo.UseShellExecute = false; + p.StartInfo.RedirectStandardInput = true; + p.StartInfo.RedirectStandardOutput = true; + p.StartInfo.CreateNoWindow = true; + p.OutputDataReceived += _mplayer_OutputDataReceived; + + try + { + p.Start(); + } + catch + { + return false; + } + p.BeginOutputReadLine(); // Async reading of output to prevent deadlock + if (p.WaitForExit(9000)) + { + return true; + } + return false; + } + + void _mplayer_OutputDataReceived(object sender, DataReceivedEventArgs e) + { + if (e != null && e.Data != null) + Result = e.Data; + } + } +} diff --git a/src/UpdateAssemblyDescription/Program.cs b/src/UpdateAssemblyDescription/Program.cs new file mode 100644 index 000000000..dd11a681d --- /dev/null +++ b/src/UpdateAssemblyDescription/Program.cs @@ -0,0 +1,86 @@ +using System; +using System.IO; + +namespace UpdateAssemblyDescription +{ + class Program + { + + private static string GetGitPath() + { + string p = Path.Combine(Environment.GetEnvironmentVariable("ProgramFiles"), @"Git\bin\git.exe"); + if (File.Exists(p)) + return p; + + p = Path.Combine(Environment.GetEnvironmentVariable("ProgramFiles(x86)"), @"Git\bin\git.exe"); + if (File.Exists(p)) + return p; + + p = @"C:\Program Files\Git\bin\git.exe"; + if (File.Exists(p)) + return p; + + p = @"C:\Program Files (x86)\Git\bin\git.exe"; + if (File.Exists(p)) + return p; + + p = @"C:\Git\bin\git.exe"; + if (File.Exists(p)) + return p; + + return "git"; + } + + private static void DoUpdateAssemblyDescription(string gitHash, string template, string target) + { + string templateData = File.ReadAllText(template); + string fixedData = templateData.Replace("[GITHASH]", gitHash); + File.WriteAllText(target, fixedData); + } + + static int Main(string[] args) + { + string errorFileName = System.Reflection.Assembly.GetEntryAssembly().Location.Replace(".exe", "_error.txt"); + + if (args.Length != 2) + { + Console.WriteLine("UpdateAssemblyDescription 0.9"); + Console.WriteLine("UpdateAssemblyDescription