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 |
dict.Add("Enterprise.Logging.dll", typeof(Enterprise.Logging.gLog)); |
95 |
#endregion |
96 |
|
97 |
#region extra plugins |
98 |
dict.Add("RomCheater.CheatPlugin.dlll", typeof(RomCheater.CheatPlugin.CheatCodePlugin)); |
99 |
dict.Add("RomCheater.EmuMMAPPlugin.dlll", typeof(RomCheater.EmuMMAPPlugin.EmuMMAPPlugin)); |
100 |
dict.Add("RomCheater.RVACheatList.dlll", typeof(RomCheater.RVACheatList.RVACheatListPlugin)); |
101 |
dict.Add("RomCheater.ScratchPad.dlll", typeof(RomCheater.ScratchPad.ScratchPadPlugin)); |
102 |
#endregion |
103 |
#endregion |
104 |
|
105 |
return dict; |
106 |
} |
107 |
} |
108 |
} |