ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/RomCheater/trunk/MSBuild_CurrentVersion/Program.cs
Revision: 812
Committed: Tue Apr 15 14:52:10 2014 UTC (9 years, 7 months ago) by william
File size: 4304 byte(s)
Log Message:
+ update logging to use Enterpise.Logging -- more work is still needed

File Contents

# Content
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Reflection;
6 using System.Diagnostics;
7
8 using RomCheater;
9 using RomCheater.CorePlugins;
10 using RomCheater.Logging;
11 using RomCheater.PluginFramework;
12 using RomCheater.UserSettingsSupport;
13 using System.IO;
14
15 namespace MSBuild_CurrentVersion
16 {
17 class Program
18 {
19
20 static void Main(string[] args)
21 {
22 Assembly this_asm = typeof(Program).Assembly;
23
24 string asm_path = this_asm.Location.Replace(@"\MSBuild_CurrentVersion.exe", "");
25
26 string version_file = "current-version.txt";
27 string full_path = string.Format(@"{0}\{1}", asm_path,version_file);
28 FileInfo fi = new FileInfo(full_path);
29 if (fi.Exists) fi.Delete();
30 using (FileStream fs = new FileStream(full_path, FileMode.CreateNew, FileAccess.ReadWrite, FileShare.ReadWrite))
31 {
32 StreamWriter sw = new StreamWriter(fs);
33 sw.AutoFlush = true;
34 Dictionary<string, Type> dict = CreateAssemblyDictonary();
35 Console.WriteLine("Current Version:");
36 sw.WriteLine("Current Version:");
37 foreach (KeyValuePair<string, Type> pair in dict)
38 {
39 Type t = pair.Value;
40 Assembly asm = t.Assembly;
41 //string ns = string.Format("{0}", t.Namespace);
42 //if (ns.Contains("CorePlugins")) { ns = string.Format("{0}.{1}", t.Namespace, t.Name); }
43 //if (ns.Contains("Be.Windows.Forms")) { ns = pair.Key; }
44 FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(asm.Location);
45 string version = fvi.FileVersion;
46 #if DEBUG
47 version = string.Format("{0}", version);
48
49 #endif
50 #if RELEASE
51 version = version.Replace("-debug", "-release");
52 #endif
53
54 Console.WriteLine(string.Format(" {0} v{1}-{2}", pair.Key, version, GetAssemblyArchitecture(asm)));
55 sw.WriteLine(string.Format(" {0} v{1}-{2}", pair.Key, version, GetAssemblyArchitecture(asm)));
56 }
57 sw.Close();
58 }
59 }
60
61 static string GetAssemblyArchitecture(Assembly t)
62 {
63 IEnumerable<ProcessorAssemblyArchitecture> attributes = t.GetCustomAttributes(typeof(ProcessorAssemblyArchitecture), false).ToList().Cast<ProcessorAssemblyArchitecture>();
64
65 foreach (ProcessorAssemblyArchitecture arch in attributes)
66 {
67 return arch.Architecture;
68 }
69 return ProcessorAssemblyArchitecture.GetProcessorArchitecture(t);
70 }
71
72 static Dictionary<string, Type> CreateAssemblyDictonary()
73 {
74 Dictionary<string, Type> dict = new Dictionary<string, Type>();
75
76 #region assemblies
77 dict.Add("RomCheater.Core.dll", typeof(RomCheater.Core.dummy));
78 dict.Add("RomCheater.exe", typeof(RomCheater.Main));
79 dict.Add("RomCheater.Logging.dll", typeof(RomCheater.Logging.LoggingConstants));
80 dict.Add("RomCheater.PluginFramework.dll", typeof(RomCheater.PluginFramework.dummy));
81 dict.Add("RomCheater.UserSettingsSupport.dll", typeof(RomCheater.UserSettingsSupport.SettingSubscriber));
82 dict.Add("RomCheater.CorePlugins.dll", typeof(RomCheater.CorePlugins.Config.GenericConfig));
83
84 dict.Add("libWin32.dll", typeof(libWin32.dummy));
85 dict.Add("Sojaner.MemoryScanner.dll", typeof(Sojaner.MemoryScanner.dummy));
86
87
88
89 #region deps
90 dict.Add("Be.Windows.Forms.HexBox.dll", typeof(Be.Windows.Forms.HexBox));
91 dict.Add("Utilities.TransparentControls.dll", typeof(Utilities.TransparentControls.Win32));
92 dict.Add("ManagedWinapi.dll", typeof(ManagedWinapi.ClipboardNotifier));
93 dict.Add("WeifenLuo.WinFormsUI.Docking.dll", typeof(WeifenLuo.WinFormsUI.Docking.DockPanel));
94 #endregion
95
96 #endregion
97
98 return dict;
99 }
100 }
101 }