using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Reflection; using System.Diagnostics; using RomCheater; using RomCheater.CorePlugins; using RomCheater.Logging; using RomCheater.PluginFramework; using RomCheater.UserSettingsSupport; using System.IO; namespace MSBuild_CurrentVersion { class Program { static void Main(string[] args) { Assembly this_asm = typeof(Program).Assembly; string asm_path = this_asm.Location.Replace(@"\MSBuild_CurrentVersion.exe", ""); string version_file = "current-version.txt"; string full_path = string.Format(@"{0}\{1}", asm_path,version_file); using (FileStream fs = new FileStream(full_path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite)) { StreamWriter sw = new StreamWriter(fs); sw.AutoFlush = true; Dictionary dict = CreateAssemblyDictonary(); Console.WriteLine("Current Version:"); sw.WriteLine("Current Version:"); foreach (KeyValuePair pair in dict) { Type t = pair.Value; Assembly asm = t.Assembly; //string ns = string.Format("{0}", t.Namespace); //if (ns.Contains("CorePlugins")) { ns = string.Format("{0}.{1}", t.Namespace, t.Name); } //if (ns.Contains("Be.Windows.Forms")) { ns = pair.Key; } FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(asm.Location); Console.WriteLine(string.Format(" {0} v{1}-{2}", pair.Key, fvi.FileVersion, GetAssemblyArchitecture(asm))); sw.WriteLine(string.Format(" {0} v{1}-{2}", pair.Key, fvi.FileVersion, GetAssemblyArchitecture(asm))); } sw.Close(); } } static string GetAssemblyArchitecture(Assembly t) { IEnumerable attributes = t.GetCustomAttributes(typeof(ProcessorAssemblyArchitecture), false).ToList().Cast(); foreach (ProcessorAssemblyArchitecture arch in attributes) { return arch.Architecture; } return ProcessorAssemblyArchitecture.GetProcessorArchitecture(t); } static Dictionary CreateAssemblyDictonary() { Dictionary dict = new Dictionary(); #region assemblies dict.Add("RomCheater.Core.dll", typeof(RomCheater.Core.dummy)); dict.Add("RomCheater.exe", typeof(RomCheater.Main)); dict.Add("RomCheater.Logging.dll", typeof(RomCheater.Logging.logger)); dict.Add("RomCheater.PluginFramework.dll", typeof(RomCheater.PluginFramework.dummy)); dict.Add("RomCheater.UserSettingsSupport.dll", typeof(RomCheater.UserSettingsSupport.SettingSubscriber)); dict.Add("RomCheater.CorePlugins.dll", typeof(RomCheater.CorePlugins.Config.GenericConfig)); dict.Add("libWin32.dll", typeof(libWin32.dummy)); dict.Add("Sojaner.MemoryScanner.dll", typeof(Sojaner.MemoryScanner.dummy)); #region deps dict.Add("Be.Windows.Forms.HexBox.dll", typeof(Be.Windows.Forms.HexBox)); dict.Add("Utilities.TransparentControls.dll", typeof(Utilities.TransparentControls.Win32)); dict.Add("ManagedWinapi.dll", typeof(ManagedWinapi.ClipboardNotifier)); //dict.Add("WeifenLuo.WinFormsUI.Docking.dll", typeof(WeifenLuo.WinFormsUI.Docking.DockPanel)); #endregion #endregion return dict; } } }