ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/RomCheater/trunk/MSBuild_CurrentVersion/Program.cs
Revision: 186
Committed: Mon May 28 10:26:01 2012 UTC (11 years, 6 months ago) by william
File size: 4204 byte(s)
Log Message:
fix appendage of -release in current-version.txt

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 using (FileStream fs = new FileStream(full_path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite))
29 {
30 StreamWriter sw = new StreamWriter(fs);
31 sw.AutoFlush = true;
32 Dictionary<string, Type> dict = CreateAssemblyDictonary();
33 Console.WriteLine("Current Version:");
34 sw.WriteLine("Current Version:");
35 foreach (KeyValuePair<string, Type> pair in dict)
36 {
37 Type t = pair.Value;
38 Assembly asm = t.Assembly;
39 //string ns = string.Format("{0}", t.Namespace);
40 //if (ns.Contains("CorePlugins")) { ns = string.Format("{0}.{1}", t.Namespace, t.Name); }
41 //if (ns.Contains("Be.Windows.Forms")) { ns = pair.Key; }
42 FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(asm.Location);
43 string version = fvi.FileVersion;
44 #if DEBUG
45 version = string.Format("{0}", version);
46
47 #endif
48 #if RELEASE
49 version = version.Replace("-debug", "-release");
50 #endif
51
52 Console.WriteLine(string.Format(" {0} v{1}-{2}", pair.Key, version, GetAssemblyArchitecture(asm)));
53 sw.WriteLine(string.Format(" {0} v{1}-{2}", pair.Key, version, GetAssemblyArchitecture(asm)));
54 }
55 sw.Close();
56 }
57 }
58
59 static string GetAssemblyArchitecture(Assembly t)
60 {
61 IEnumerable<ProcessorAssemblyArchitecture> attributes = t.GetCustomAttributes(typeof(ProcessorAssemblyArchitecture), false).ToList().Cast<ProcessorAssemblyArchitecture>();
62
63 foreach (ProcessorAssemblyArchitecture arch in attributes)
64 {
65 return arch.Architecture;
66 }
67 return ProcessorAssemblyArchitecture.GetProcessorArchitecture(t);
68 }
69
70 static Dictionary<string, Type> CreateAssemblyDictonary()
71 {
72 Dictionary<string, Type> dict = new Dictionary<string, Type>();
73
74 #region assemblies
75 dict.Add("RomCheater.Core.dll", typeof(RomCheater.Core.dummy));
76 dict.Add("RomCheater.exe", typeof(RomCheater.Main));
77 dict.Add("RomCheater.Logging.dll", typeof(RomCheater.Logging.logger));
78 dict.Add("RomCheater.PluginFramework.dll", typeof(RomCheater.PluginFramework.dummy));
79 dict.Add("RomCheater.UserSettingsSupport.dll", typeof(RomCheater.UserSettingsSupport.SettingSubscriber));
80 dict.Add("RomCheater.CorePlugins.dll", typeof(RomCheater.CorePlugins.Config.GenericConfig));
81
82 dict.Add("libWin32.dll", typeof(libWin32.dummy));
83 dict.Add("Sojaner.MemoryScanner.dll", typeof(Sojaner.MemoryScanner.dummy));
84
85
86
87 #region deps
88 dict.Add("Be.Windows.Forms.HexBox.dll", typeof(Be.Windows.Forms.HexBox));
89 dict.Add("Utilities.TransparentControls.dll", typeof(Utilities.TransparentControls.Win32));
90 dict.Add("ManagedWinapi.dll", typeof(ManagedWinapi.ClipboardNotifier));
91 dict.Add("WeifenLuo.WinFormsUI.Docking.dll", typeof(WeifenLuo.WinFormsUI.Docking.DockPanel));
92 #endregion
93
94 #endregion
95
96 return dict;
97 }
98 }
99 }