Skip to content

Commit

Permalink
Update version string
Browse files Browse the repository at this point in the history
  • Loading branch information
MrHinsh committed Jul 12, 2024
1 parent ca6b0ef commit c0a37c7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
6 changes: 4 additions & 2 deletions src/MigrationTools.Host/Services/DetectVersionService2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,13 @@ private WinGetPackage GetPackage()
return _package;
}

public static (Version version, string PreReleaseLabel) GetRunningVersion()
public static (Version version, string PreReleaseLabel, string versionString) GetRunningVersion()
{
FileVersionInfo myFileVersionInfo = FileVersionInfo.GetVersionInfo(Assembly.GetEntryAssembly()?.Location);
var matches = Regex.Matches(myFileVersionInfo.ProductVersion, @"^(?<major>0|[1-9]\d*)\.(?<minor>0|[1-9]\d*)\.(?<build>0|[1-9]\d*)(?:-((?<label>:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?<fullEnd>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$");
return (new Version(myFileVersionInfo.FileVersion), matches[0].Groups[1].Value);
Version version = new Version(myFileVersionInfo.FileVersion);
string textVersion = "v" + version.Major + "." + version.Minor + "." + version.Build + "-" + matches[0].Groups[1].Value;
return (version, matches[0].Groups[1].Value, textVersion);
}
}

Expand Down
11 changes: 5 additions & 6 deletions src/MigrationTools.Host/StartupService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,14 @@ public void RunExitLogic()
private void ApplicationStartup(string[] args)
{
_mainTimer.Start();
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
var version = Assembly.GetEntryAssembly().GetName().Version;
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
_logger.LogInformation("Application Starting");
AsciiLogo(version);
AsciiLogo(DetectVersionService2.GetRunningVersion().versionString);
TelemetryNote();
_logger.LogInformation("Start Time: {StartTime}", DateTime.Now.ToUniversalTime().ToLocalTime());
_logger.LogInformation("Running with args: {@Args}", args);
_logger.LogInformation("OSVersion: {OSVersion}", Environment.OSVersion.ToString());
_logger.LogInformation("Version (Assembly): {Version}", version);
_logger.LogInformation("Version (Assembly): {Version}", DetectVersionService2.GetRunningVersion().versionString);
}

protected void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
Expand All @@ -166,7 +165,7 @@ private void TelemetryNote()
_logger.LogInformation("--------------------------------------");
}

private void AsciiLogo(Version thisVersion)
private void AsciiLogo(string thisVersion)
{
_logger.LogInformation(" &@& ");
_logger.LogInformation(" @@(((((@ ");
Expand Down Expand Up @@ -209,7 +208,7 @@ private void AsciiLogo(Version thisVersion)
var productName = ((AssemblyProductAttribute)Assembly.GetEntryAssembly()
.GetCustomAttributes(typeof(AssemblyProductAttribute), true)[0]).Product;
_logger.LogInformation("{productName} ", productName);
_logger.LogInformation("v{thisVersion}", thisVersion);
_logger.LogInformation("{thisVersion}", thisVersion);
var companyName = ((AssemblyCompanyAttribute)Assembly.GetEntryAssembly()
.GetCustomAttributes(typeof(AssemblyCompanyAttribute), true)[0]).Company;
_logger.LogInformation("{companyName} ", companyName);
Expand Down

0 comments on commit c0a37c7

Please sign in to comment.