/[RomCheater]/trunk/MSBuild_CurrentVersion/Program.cs
ViewVC logotype

Annotation of /trunk/MSBuild_CurrentVersion/Program.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 181 - (hide annotations) (download)
Mon May 28 10:03:08 2012 UTC (9 years, 1 month ago) by william
File size: 4187 byte(s)

1 william 117 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 william 181 string version = fvi.FileVersion;
44     #if DEBUG
45     version.Replace("-release", "-debug");
46     #endif
47     #if RELEASE
48     version.Replace("-debug", "-release");
49     #endif
50    
51 william 118 Console.WriteLine(string.Format(" {0} v{1}-{2}", pair.Key, fvi.FileVersion, GetAssemblyArchitecture(asm)));
52     sw.WriteLine(string.Format(" {0} v{1}-{2}", pair.Key, fvi.FileVersion, GetAssemblyArchitecture(asm)));
53 william 117 }
54     sw.Close();
55     }
56     }
57    
58     static string GetAssemblyArchitecture(Assembly t)
59     {
60     IEnumerable<ProcessorAssemblyArchitecture> attributes = t.GetCustomAttributes(typeof(ProcessorAssemblyArchitecture), false).ToList().Cast<ProcessorAssemblyArchitecture>();
61    
62     foreach (ProcessorAssemblyArchitecture arch in attributes)
63     {
64 william 118 return arch.Architecture;
65 william 117 }
66 william 118 return ProcessorAssemblyArchitecture.GetProcessorArchitecture(t);
67 william 117 }
68    
69     static Dictionary<string, Type> CreateAssemblyDictonary()
70     {
71     Dictionary<string, Type> dict = new Dictionary<string, Type>();
72    
73     #region assemblies
74 william 119 dict.Add("RomCheater.Core.dll", typeof(RomCheater.Core.dummy));
75     dict.Add("RomCheater.exe", typeof(RomCheater.Main));
76 william 117 dict.Add("RomCheater.Logging.dll", typeof(RomCheater.Logging.logger));
77     dict.Add("RomCheater.PluginFramework.dll", typeof(RomCheater.PluginFramework.dummy));
78     dict.Add("RomCheater.UserSettingsSupport.dll", typeof(RomCheater.UserSettingsSupport.SettingSubscriber));
79     dict.Add("RomCheater.CorePlugins.dll", typeof(RomCheater.CorePlugins.Config.GenericConfig));
80    
81     dict.Add("libWin32.dll", typeof(libWin32.dummy));
82     dict.Add("Sojaner.MemoryScanner.dll", typeof(Sojaner.MemoryScanner.dummy));
83    
84    
85    
86     #region deps
87     dict.Add("Be.Windows.Forms.HexBox.dll", typeof(Be.Windows.Forms.HexBox));
88     dict.Add("Utilities.TransparentControls.dll", typeof(Utilities.TransparentControls.Win32));
89 william 124 dict.Add("ManagedWinapi.dll", typeof(ManagedWinapi.ClipboardNotifier));
90 william 143 dict.Add("WeifenLuo.WinFormsUI.Docking.dll", typeof(WeifenLuo.WinFormsUI.Docking.DockPanel));
91 william 117 #endregion
92    
93     #endregion
94    
95     return dict;
96     }
97     }
98     }

  ViewVC Help
Powered by ViewVC 1.1.22