diff --git a/adrilight/MainForm.cs b/adrilight/MainForm.cs
index 88f01ed..25309d3 100644
--- a/adrilight/MainForm.cs
+++ b/adrilight/MainForm.cs
@@ -14,13 +14,13 @@
using Newtonsoft.Json.Linq;
using NLog;
using Semver;
+using System.Reflection;
+using System.IO;
namespace adrilight {
public partial class MainForm : Form
{
- private const string CURRENT_VERSION = "0.1.4";
-
private readonly ILogger _log = LogManager.GetCurrentClassLogger();
private NotifyIcon _mNotifyIcon;
@@ -31,6 +31,8 @@ public partial class MainForm : Form
public MainForm() {
_log.Debug("Creating Mainform");
InitializeComponent();
+ Text += " " + Program.VersionNumber;
+
InitTrayIcon();
Application.ApplicationExit += OnApplicationExit;
@@ -46,23 +48,21 @@ private void StartVersionCheck()
{
try
{
- var currentVersion = SemVersion.Parse(CURRENT_VERSION);
-
dynamic latestRelease = TryGetLatestReleaseData().Result;
if (latestRelease == null) return;
string tagName = latestRelease.tag_name;
- var latestVersionNumber = SemVersion.Parse(tagName.TrimStart('v','V'));
+ var latestVersionNumber = SemVersion.Parse(tagName.TrimStart('v', 'V'));
- if (latestVersionNumber > currentVersion)
+ if (latestVersionNumber > Program.VersionNumber)
{
- Invoke((MethodInvoker) delegate
+ Invoke((MethodInvoker)delegate
{
var url = latestRelease.html_url as string;
- var shouldOpenUrl = MessageBox.Show($"New version of adrilight is available! The new version is {latestVersionNumber} (you are running {currentVersion}). Press OK to open the download page."
- , "New Adrilight Version!", MessageBoxButtons.OKCancel) == DialogResult.OK;
+ var shouldOpenUrl = MessageBox.Show($"New version of adrilight is available! The new version is {latestVersionNumber} (you are running {Program.VersionNumber}). Press OK to open the download page."
+ , "New Adrilight Version!", MessageBoxButtons.OKCancel) == DialogResult.OK;
- if (url!=null && shouldOpenUrl)
+ if (url != null && shouldOpenUrl)
{
Process.Start(url);
}
diff --git a/adrilight/Program.cs b/adrilight/Program.cs
index d9062b7..005bfc8 100644
--- a/adrilight/Program.cs
+++ b/adrilight/Program.cs
@@ -1,5 +1,7 @@
using NLog;
using System;
+using System.IO;
+using System.Reflection;
using System.Text;
using System.Threading;
using System.Windows.Forms;
@@ -16,7 +18,7 @@ static class Program {
[STAThread]
static void Main()
{
- _log.Debug("Main() started.");
+ _log.Debug($"adrilight {VersionNumber}: Main() started.");
Settings.Refresh();
@@ -32,7 +34,7 @@ static void Main()
private static void ApplicationOnThreadException(object sender, Exception ex)
{
- _log.Fatal(ex, $"ApplicationOnThreadException from sender={sender}");
+ _log.Fatal(ex, $"ApplicationOnThreadException from sender={sender}, adrilight version={VersionNumber}");
var sb = new StringBuilder();
sb.AppendLine($"Sender: {sender}");
@@ -53,5 +55,18 @@ private static void ApplicationOnThreadException(object sender, Exception ex)
MessageBox.Show(sb.ToString(), "unhandled exception :-(");
Application.Exit();
}
+
+ public static string VersionNumber { get; } = GetVersionNumber();
+
+ private static string GetVersionNumber()
+ {
+ var assembly = Assembly.GetExecutingAssembly();
+ string currentVersion;
+ using (var versionStream = assembly.GetManifestResourceStream("adrilight.version.txt"))
+ {
+ currentVersion = new StreamReader(versionStream).ReadToEnd().Trim();
+ }
+ return currentVersion;
+ }
}
}
diff --git a/adrilight/adrilight.csproj b/adrilight/adrilight.csproj
index a5515d9..567e95d 100644
--- a/adrilight/adrilight.csproj
+++ b/adrilight/adrilight.csproj
@@ -135,6 +135,9 @@
Overlay.cs
+
+ version.txt
+
Always
diff --git a/create_release.bat b/create_release.bat
new file mode 100644
index 0000000..cd45a66
--- /dev/null
+++ b/create_release.bat
@@ -0,0 +1,3 @@
+powershell -ExecutionPolicy RemoteSigned -File create_release.ps1
+
+pause
\ No newline at end of file
diff --git a/create_release.ps1 b/create_release.ps1
new file mode 100644
index 0000000..8a4a87c
--- /dev/null
+++ b/create_release.ps1
@@ -0,0 +1,27 @@
+$version = gc .\version.txt
+
+del ".\Release\adrilight_$version.zip" -Force -ErrorAction SilentlyContinue
+rm ".\Release\adrilight_$version" -Force -Recurse -ErrorAction SilentlyContinue
+md ".\Release\adrilight_$version\PC" -Force
+
+#find msbuild
+$_decSep = [System.Threading.Thread]::CurrentThread.CurrentUICulture.NumberFormat.CurrencyDecimalSeparator;
+$msbuild = $(Get-ChildItem -Path "HKLM:\SOFTWARE\Wow6432Node\Microsoft\MSBuild\ToolsVersions\" |
+ Where { $_.Name -match '\\\d+.\d+$' } |
+ Sort-Object -property @{Expression={[System.Convert]::ToDecimal($_.Name.Substring($_.Name.LastIndexOf("\") + 1).Replace(".",$_decSep).Replace(",",$_decSep))}} -Descending |
+ Select-Object -First 1).GetValue("MSBuildToolsPath") + "msbuild.exe"
+
+if((Test-Path -Path $msbuild) -eq $false) {Write-Error "failed to find msbuild file"; exit}
+
+& $msbuild /m .\adrilight.sln /t:Clean /p:Configuration=Release
+& $msbuild /m .\adrilight.sln /t:Rebuild /p:Configuration=Release
+
+dir Arduino -Recurse | Copy -Destination ".\Release\adrilight_$version\Arduino\"
+dir .\adrilight\bin\Release -Exclude "*.pdb","*vshost*","logs" | Copy -Destination ".\Release\adrilight_$version\PC\"
+
+Compress-Archive -Path ".\Release\adrilight_$version\*" -DestinationPath ".\Release\adrilight_$version.zip" -Force -CompressionLevel Optimal
+
+write-host
+Write-Host "adrilight_$version.zip created!" -ForegroundColor Green
+Write-Host "full path:" -ForegroundColor Gray
+Write-Host (dir ".\Release\adrilight_$version.zip").FullName -ForegroundColor Yellow
diff --git a/version.txt b/version.txt
new file mode 100644
index 0000000..446ba66
--- /dev/null
+++ b/version.txt
@@ -0,0 +1 @@
+0.1.4
\ No newline at end of file