make Novetus.Launch use NovetusCore. Add "%compile-date%".
This commit is contained in:
parent
00a220195b
commit
d65d6c4460
|
|
@ -3,6 +3,7 @@ using System;
|
|||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
#endregion
|
||||
|
||||
namespace Novetus.Launch
|
||||
|
|
@ -20,25 +21,7 @@ namespace Novetus.Launch
|
|||
|
||||
public static void LaunchApplication(string appName, string args = "")
|
||||
{
|
||||
LaunchApplicationExt(LocalPaths.BinPath, appName, args);
|
||||
}
|
||||
|
||||
public static string GetVersion(string infopath)
|
||||
{
|
||||
//READ
|
||||
string version;
|
||||
INIFile ini = new INIFile(infopath);
|
||||
string section = "ProgramInfo";
|
||||
bool extendedversionnumber = Convert.ToBoolean(ini.IniReadValue(section, "ExtendedVersionNumber", "False"));
|
||||
version = (extendedversionnumber ? ini.IniReadValue(section, "ExtendedVersionTemplate", "%version%") : ini.IniReadValue(section, "Branch", "0.0"));
|
||||
|
||||
var versionInfo = FileVersionInfo.GetVersionInfo(LocalPaths.BinPath + "\\" + LocalPaths.LauncherName);
|
||||
string extendedversionrevision = ini.IniReadValue(section, "ExtendedVersionRevision", "1");
|
||||
version = version.Replace("%version%", ini.IniReadValue(section, "Branch", "0.0"))
|
||||
.Replace("%build%", versionInfo.ProductBuildPart.ToString())
|
||||
.Replace("%revision%", versionInfo.FilePrivatePart.ToString())
|
||||
.Replace("%extended-revision%", extendedversionrevision);
|
||||
return version;
|
||||
LaunchApplicationExt(LocalPaths.FixedBinDir, appName, args);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
|
|
|||
|
|
@ -9,19 +9,19 @@ namespace Novetus.Launch
|
|||
|
||||
public class LocalPaths
|
||||
{
|
||||
#region Base Paths
|
||||
public static readonly string RootPathLauncher = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
||||
public static readonly string BasePathLauncher = RootPathLauncher.Replace(@"\", @"\\");
|
||||
public static readonly string BinPath = BasePathLauncher + @"\\bin";
|
||||
public static readonly string ConfigPath = BasePathLauncher + @"\\config";
|
||||
#endregion
|
||||
public static readonly string FixedBinDir = GlobalPaths.BasePathLauncher + @"\\bin";
|
||||
public static readonly string FixedConfigDir = GlobalPaths.BasePathLauncher + @"\\config";
|
||||
|
||||
#region File Names
|
||||
public static readonly string LauncherName = "Novetus.exe";
|
||||
public static readonly string CMDName = "NovetusCMD.exe";
|
||||
public static readonly string URIName = "NovetusURI.exe";
|
||||
public static readonly string DependencyLauncherName = "Novetus_dependency_installer.bat";
|
||||
public static readonly string LauncherInfoFile = "info.ini";
|
||||
#endregion
|
||||
|
||||
#region File Paths
|
||||
public static readonly string LauncherPath = FixedBinDir + "\\" + LauncherName;
|
||||
public static readonly string InfoPath = FixedConfigDir + "\\" + GlobalPaths.InfoName;
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DefineConstants>TRACE;DEBUG;BASICLAUNCHER</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
|
|
@ -47,9 +47,6 @@
|
|||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\NovetusCore\Classes\INIFile.cs">
|
||||
<Link>INIFile.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="LocalPaths.cs" />
|
||||
<Compile Include="LocalFuncs.cs" />
|
||||
<Compile Include="NovetusLaunchForm.cs">
|
||||
|
|
@ -88,6 +85,7 @@
|
|||
<Content Include="NovetusIcon.ico" />
|
||||
<None Include="Resources\NOVETUS_new_final_smol.png" />
|
||||
</ItemGroup>
|
||||
<Import Project="..\NovetusCore\NovetusCore.projitems" Label="Shared" />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>SET path=$(SolutionDir)build
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@ namespace Novetus.Launch
|
|||
//use novetus font for label!!
|
||||
//https://stackoverflow.com/questions/1297264/using-custom-fonts-on-a-label-on-winforms
|
||||
|
||||
GlobalFuncs.ReadInfoFile(LocalPaths.InfoPath, true, LocalPaths.LauncherPath);
|
||||
|
||||
PrivateFontCollection pfc = new PrivateFontCollection();
|
||||
int fontLength = Properties.Resources.Montserrat_SemiBold.Length;
|
||||
byte[] fontdata = Properties.Resources.Montserrat_SemiBold;
|
||||
|
|
@ -26,7 +28,7 @@ namespace Novetus.Launch
|
|||
pfc.AddMemoryFont(data, fontLength);
|
||||
|
||||
VersionLabel.Font = new Font(pfc.Families[0], VersionLabel.Font.Size);
|
||||
VersionLabel.Text = LocalFuncs.GetVersion(LocalPaths.ConfigPath + @"\\" + LocalPaths.LauncherInfoFile).ToUpper();
|
||||
VersionLabel.Text = GlobalVars.ProgramInformation.Version.ToUpper();
|
||||
|
||||
LaunchNovetusButton.Font = new Font(pfc.Families[0], VersionLabel.Font.Size);
|
||||
|
||||
|
|
@ -59,7 +61,7 @@ namespace Novetus.Launch
|
|||
|
||||
private void DependencyInstallerButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
LocalFuncs.LaunchApplicationExt(LocalPaths.BasePathLauncher, LocalPaths.DependencyLauncherName);
|
||||
LocalFuncs.LaunchApplicationExt(GlobalPaths.BasePathLauncher, LocalPaths.DependencyLauncherName);
|
||||
Close();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ Global
|
|||
GlobalSection(SharedMSBuildProjectFiles) = preSolution
|
||||
NovetusCore\NovetusCore.projitems*{2070eaa6-7606-4006-a628-5705c24a3644}*SharedItemsImports = 4
|
||||
NovetusCore\NovetusCore.projitems*{bac99c87-f6c1-4ed0-aa2e-05c6ae8979ea}*SharedItemsImports = 4
|
||||
NovetusCore\NovetusCore.projitems*{d7b467ee-a4b9-42fb-aa83-f487da0f5cb1}*SharedItemsImports = 4
|
||||
NovetusCore\NovetusCore.projitems*{debcc57d-9a3b-4d7c-8693-fa4aec56c8c1}*SharedItemsImports = 13
|
||||
NovetusCore\NovetusCore.projitems*{f92ffbed-2767-4676-9711-bb89cda58a43}*SharedItemsImports = 4
|
||||
EndGlobalSection
|
||||
|
|
|
|||
|
|
@ -136,7 +136,8 @@ namespace NovetusCMD
|
|||
|
||||
if (!LocalVars.PrintHelp)
|
||||
{
|
||||
GlobalFuncs.ReadInfoFile(GlobalPaths.ConfigDir + "\\" + GlobalPaths.InfoName, true);
|
||||
GlobalFuncs.ReadInfoFile(GlobalPaths.ConfigDir + "\\" + GlobalPaths.InfoName, true,
|
||||
GlobalPaths.RootPathLauncher + "\\Novetus.exe");
|
||||
Console.Title = "Novetus " + GlobalVars.ProgramInformation.Version + " CMD";
|
||||
|
||||
GlobalFuncs.ConsolePrint("NovetusCMD version " + GlobalVars.ProgramInformation.Version + " loaded.", 1);
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ using System.Xml.Linq;
|
|||
#region Global Functions
|
||||
public class GlobalFuncs
|
||||
{
|
||||
public static void ReadInfoFile(string infopath, bool cmd = false)
|
||||
public static void ReadInfoFile(string infopath, bool other = false, string exepath = "")
|
||||
{
|
||||
//READ
|
||||
string versionbranch, defaultclient, defaultmap, regclient1,
|
||||
|
|
@ -39,27 +39,38 @@ public class GlobalFuncs
|
|||
extendedversionnumber = ini.IniReadValue(section, "ExtendedVersionNumber", "False");
|
||||
extendedversioneditchangelog = ini.IniReadValue(section, "ExtendedVersionEditChangelog", "False");
|
||||
extendedversiontemplate = ini.IniReadValue(section, "ExtendedVersionTemplate", "%version%");
|
||||
extendedversionrevision = ini.IniReadValue(section, "ExtendedVersionRevision", "1");
|
||||
extendedversionrevision = ini.IniReadValue(section, "ExtendedVersionRevision", "-1");
|
||||
|
||||
try
|
||||
{
|
||||
GlobalVars.ExtendedVersionNumber = Convert.ToBoolean(extendedversionnumber);
|
||||
if (GlobalVars.ExtendedVersionNumber)
|
||||
{
|
||||
if (cmd)
|
||||
if (other)
|
||||
{
|
||||
var versionInfo = FileVersionInfo.GetVersionInfo(GlobalPaths.RootPathLauncher + "\\Novetus.exe");
|
||||
GlobalVars.ProgramInformation.Version = extendedversiontemplate.Replace("%version%", versionbranch)
|
||||
.Replace("%build%", versionInfo.ProductBuildPart.ToString())
|
||||
.Replace("%revision%", versionInfo.FilePrivatePart.ToString())
|
||||
.Replace("%extended-revision%", extendedversionrevision);
|
||||
if (!string.IsNullOrWhiteSpace(exepath))
|
||||
{
|
||||
string dateformat = GetLinkerTimestampUtc(exepath).ToString("MM.yyyy");
|
||||
var versionInfo = FileVersionInfo.GetVersionInfo(exepath);
|
||||
GlobalVars.ProgramInformation.Version = extendedversiontemplate.Replace("%version%", versionbranch)
|
||||
.Replace("%build%", versionInfo.ProductBuildPart.ToString())
|
||||
.Replace("%revision%", versionInfo.FilePrivatePart.ToString())
|
||||
.Replace("%extended-revision%", (!extendedversionrevision.Equals("-1") ? extendedversionrevision : ""))
|
||||
.Replace("%compile-date%", dateformat);
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string dateformat = GetLinkerTimestampUtc(Assembly.GetExecutingAssembly()).ToString("MM.yyyy");
|
||||
GlobalVars.ProgramInformation.Version = extendedversiontemplate.Replace("%version%", versionbranch)
|
||||
.Replace("%build%", Assembly.GetExecutingAssembly().GetName().Version.Build.ToString())
|
||||
.Replace("%revision%", Assembly.GetExecutingAssembly().GetName().Version.Revision.ToString())
|
||||
.Replace("%extended-revision%", extendedversionrevision);
|
||||
.Replace("%extended-revision%", (!extendedversionrevision.Equals("-1") ? extendedversionrevision : ""))
|
||||
.Replace("%compile-date%", dateformat);
|
||||
}
|
||||
|
||||
bool changelogedit = Convert.ToBoolean(extendedversioneditchangelog);
|
||||
|
|
@ -95,7 +106,7 @@ public class GlobalFuncs
|
|||
}
|
||||
catch (Exception)
|
||||
{
|
||||
ReadInfoFile(infopath, cmd);
|
||||
ReadInfoFile(infopath, other);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1696,11 +1707,13 @@ public class GlobalFuncs
|
|||
return Regex.Replace(lines, @"^\s*$\n|\r", string.Empty, RegexOptions.Multiline).TrimEnd();
|
||||
}
|
||||
|
||||
#if !BASICLAUNCHER
|
||||
//task.delay is only available on net 4.5.......
|
||||
public static async void Delay(int miliseconds)
|
||||
{
|
||||
await TaskEx.Delay(miliseconds);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Credit to Carrot for the original code. Rewote it to be smaller.
|
||||
public static string CryptStringWithByte(string word)
|
||||
|
|
@ -1750,5 +1763,29 @@ public class GlobalFuncs
|
|||
adjustedSize,
|
||||
SizeSuffixes[mag]);
|
||||
}
|
||||
|
||||
//https://www.meziantou.net/getting-the-date-of-build-of-a-dotnet-assembly-at-runtime.htm
|
||||
public static DateTime GetLinkerTimestampUtc(Assembly assembly)
|
||||
{
|
||||
var location = assembly.Location;
|
||||
return GetLinkerTimestampUtc(location);
|
||||
}
|
||||
|
||||
public static DateTime GetLinkerTimestampUtc(string filePath)
|
||||
{
|
||||
const int peHeaderOffset = 60;
|
||||
const int linkerTimestampOffset = 8;
|
||||
var bytes = new byte[2048];
|
||||
|
||||
using (var file = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||
{
|
||||
file.Read(bytes, 0, bytes.Length);
|
||||
}
|
||||
|
||||
var headerPos = BitConverter.ToInt32(bytes, peHeaderOffset);
|
||||
var secondsSince1970 = BitConverter.ToInt32(bytes, headerPos + linkerTimestampOffset);
|
||||
var dt = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
|
||||
return dt.AddSeconds(secondsSince1970);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ public class GlobalPaths
|
|||
public static readonly string RootPath = Directory.GetParent(RootPathLauncher).ToString();
|
||||
public static readonly string BasePath = RootPath.Replace(@"\", @"\\");
|
||||
public static readonly string DataPath = BasePath + @"\\shareddata";
|
||||
public static readonly string BinDir = BasePath + @"\\bin";
|
||||
public static readonly string ConfigDir = BasePath + @"\\config";
|
||||
public static readonly string ConfigDirClients = ConfigDir + @"\\clients";
|
||||
public static readonly string ConfigDirTemplates = ConfigDir + @"\\itemtemplates";
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#region Usings
|
||||
#if !BASICLAUNCHER
|
||||
#region Usings
|
||||
using Mono.Nat;
|
||||
using System;
|
||||
#endregion
|
||||
|
|
@ -52,3 +53,4 @@ public static class NetFuncs
|
|||
}
|
||||
}
|
||||
#endregion
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net.PeerToPeer.Collaboration;
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
|
|
|
|||
|
|
@ -267,10 +267,12 @@ public class SecurityFuncs
|
|||
return ipAddress;
|
||||
}
|
||||
|
||||
#if !BASICLAUNCHER
|
||||
public static async Task<string> GetExternalIPAddressAsync()
|
||||
{
|
||||
var task = Task.Factory.StartNew(() => GetExternalIPAddress());
|
||||
return await task;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endregion
|
||||
|
|
@ -52,6 +52,7 @@
|
|||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.Name = "InstallForm";
|
||||
this.Text = "Novetus URI Installer";
|
||||
this.Load += new System.EventHandler(this.InstallForm_Load);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,11 @@ namespace NovetusURI
|
|||
#endregion
|
||||
|
||||
#region Form Events
|
||||
private void InstallForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
CenterToScreen();
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
LocalFuncs.RegisterURI(this);
|
||||
|
|
|
|||
|
|
@ -94,6 +94,7 @@ namespace NovetusURI
|
|||
else
|
||||
{
|
||||
Visible = true;
|
||||
CenterToScreen();
|
||||
if (GlobalVars.UserConfiguration.DiscordPresence)
|
||||
{
|
||||
label1.Text = "Starting Discord Rich Presence...";
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ namespace NovetusURI
|
|||
void QuickConfigureLoad(object sender, EventArgs e)
|
||||
{
|
||||
ReadConfigValues(GlobalPaths.ConfigDir + "\\" + GlobalPaths.ConfigName);
|
||||
CenterToScreen();
|
||||
}
|
||||
|
||||
void Button3Click(object sender, EventArgs e)
|
||||
|
|
|
|||
Loading…
Reference in New Issue