diff --git a/extra/exe-builder/.gitignore b/extra/exe-builder/.gitignore new file mode 100644 index 00000000..d52874b6 --- /dev/null +++ b/extra/exe-builder/.gitignore @@ -0,0 +1 @@ +packages/ diff --git a/extra/exe-builder/App.config b/extra/exe-builder/App.config index 09265d8b..e1ab3695 100644 --- a/extra/exe-builder/App.config +++ b/extra/exe-builder/App.config @@ -1,4 +1,4 @@ - + @@ -7,4 +7,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/extra/exe-builder/DownloadForm.cs b/extra/exe-builder/DownloadForm.cs index f16af422..aed8bd29 100644 --- a/extra/exe-builder/DownloadForm.cs +++ b/extra/exe-builder/DownloadForm.cs @@ -8,6 +8,7 @@ using System.Net; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; +using Newtonsoft.Json; namespace UptimeKuma { public partial class DownloadForm : Form { @@ -23,9 +24,18 @@ namespace UptimeKuma { webClient.DownloadProgressChanged += DownloadProgressChanged; webClient.DownloadFileCompleted += DownloadFileCompleted; + label.Text = "Reading latest version..."; + + // Read json from https://uptime.kuma.pet/version + var versionObj = JsonConvert.DeserializeObject(new WebClient().DownloadString("https://uptime.kuma.pet/version")); + + + var nodeVersion = versionObj.nodejs; + var uptimeKumaVersion = versionObj.latest; + if (!Directory.Exists("node")) { downloadQueue.Enqueue(new DownloadItem { - URL = "https://nodejs.org/dist/v16.17.1/node-v16.17.1-win-x64.zip", + URL = $"https://nodejs.org/dist/v{nodeVersion}/node-v{nodeVersion}-win-x64.zip", Filename = "node.zip", TargetFolder = "node" }); @@ -33,7 +43,7 @@ namespace UptimeKuma { if (!Directory.Exists("node")) { downloadQueue.Enqueue(new DownloadItem { - URL = "https://github.com/louislam/uptime-kuma/archive/refs/tags/1.18.3.zip", + URL = $"https://github.com/louislam/uptime-kuma/archive/refs/tags/{uptimeKumaVersion}.zip", Filename = "core.zip", TargetFolder = "core" }); diff --git a/extra/exe-builder/FodyWeavers.xml b/extra/exe-builder/FodyWeavers.xml new file mode 100644 index 00000000..f1dea8fc --- /dev/null +++ b/extra/exe-builder/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/extra/exe-builder/FodyWeavers.xsd b/extra/exe-builder/FodyWeavers.xsd new file mode 100644 index 00000000..ff119f71 --- /dev/null +++ b/extra/exe-builder/FodyWeavers.xsd @@ -0,0 +1,141 @@ + + + + + + + + + + + + A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks + + + + + A list of assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks. + + + + + A list of runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks + + + + + A list of runtime assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks. + + + + + A list of unmanaged 32 bit assembly names to include, delimited with line breaks. + + + + + A list of unmanaged 64 bit assembly names to include, delimited with line breaks. + + + + + The order of preloaded assemblies, delimited with line breaks. + + + + + + This will copy embedded files to disk before loading them into memory. This is helpful for some scenarios that expected an assembly to be loaded from a physical file. + + + + + Controls if .pdbs for reference assemblies are also embedded. + + + + + Controls if runtime assemblies are also embedded. + + + + + Controls whether the runtime assemblies are embedded with their full path or only with their assembly name. + + + + + Embedded assemblies are compressed by default, and uncompressed when they are loaded. You can turn compression off with this option. + + + + + As part of Costura, embedded assemblies are no longer included as part of the build. This cleanup can be turned off. + + + + + Costura by default will load as part of the module initialization. This flag disables that behavior. Make sure you call CosturaUtility.Initialize() somewhere in your code. + + + + + Costura will by default use assemblies with a name like 'resources.dll' as a satellite resource and prepend the output path. This flag disables that behavior. + + + + + A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with | + + + + + A list of assembly names to include from the default action of "embed all Copy Local references", delimited with |. + + + + + A list of runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with | + + + + + A list of runtime assembly names to include from the default action of "embed all Copy Local references", delimited with |. + + + + + A list of unmanaged 32 bit assembly names to include, delimited with |. + + + + + A list of unmanaged 64 bit assembly names to include, delimited with |. + + + + + The order of preloaded assemblies, delimited with |. + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/extra/exe-builder/Program.cs b/extra/exe-builder/Program.cs index 82c76b05..27e345b7 100644 --- a/extra/exe-builder/Program.cs +++ b/extra/exe-builder/Program.cs @@ -8,6 +8,7 @@ using System.Reflection; using System.Runtime.InteropServices; using System.Threading.Tasks; using System.Windows.Forms; +using Microsoft.Win32; using UptimeKuma.Properties; namespace UptimeKuma { @@ -25,17 +26,27 @@ namespace UptimeKuma { public class UptimeKumaApplicationContext : ApplicationContext { + const string appName = "Uptime Kuma"; + private NotifyIcon trayIcon; private Process process; + private MenuItem runWhenStarts; + + private RegistryKey registryKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true); + public UptimeKumaApplicationContext() { trayIcon = new NotifyIcon(); + runWhenStarts = new MenuItem("Run when system starts", RunWhenStarts); + runWhenStarts.Checked = registryKey.GetValue(appName) != null; + trayIcon.Icon = Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location); trayIcon.ContextMenu = new ContextMenu(new MenuItem[] { new("Open", Open), //new("Debug Console", DebugConsole), + runWhenStarts, new("Check for Update...", CheckForUpdate), new("Visit GitHub...", VisitGitHub), new("About", About), @@ -59,6 +70,21 @@ namespace UptimeKuma { form.Show(); } + private void RunWhenStarts(object sender, EventArgs e) { + if (registryKey == null) { + MessageBox.Show("Error: Unable to set startup registry key."); + return; + } + + if (runWhenStarts.Checked) { + registryKey.DeleteValue(appName, false); + runWhenStarts.Checked = false; + } else { + registryKey.SetValue(appName, Application.ExecutablePath); + runWhenStarts.Checked = true; + } + } + void StartProcess() { var startInfo = new ProcessStartInfo { FileName = "node/node.exe", @@ -103,7 +129,7 @@ namespace UptimeKuma { void About(object sender, EventArgs e) { - MessageBox.Show("Uptime Kuma v1.0.0" + Environment.NewLine + "© 2022 Louis Lam", "Info"); + MessageBox.Show("Uptime Kuma Windows Runtime v1.0.0" + Environment.NewLine + "© 2023 Louis Lam", "Info"); } void Exit(object sender, EventArgs e) diff --git a/extra/exe-builder/UptimeKuma.csproj b/extra/exe-builder/UptimeKuma.csproj index 2ad857b2..3f55649e 100644 --- a/extra/exe-builder/UptimeKuma.csproj +++ b/extra/exe-builder/UptimeKuma.csproj @@ -1,5 +1,6 @@  + Debug @@ -38,18 +39,104 @@ COPY "$(SolutionDir)bin\Debug\uptime-kuma.exe" "%UserProfile%\Desktop\uptime-kuma-win64\" + + packages\Costura.Fody.5.7.0\lib\netstandard1.0\Costura.dll + + + packages\Microsoft.Win32.Primitives.4.3.0\lib\net46\Microsoft.Win32.Primitives.dll + + + + packages\Newtonsoft.Json.13.0.2\lib\net45\Newtonsoft.Json.dll + + + packages\System.AppContext.4.3.0\lib\net463\System.AppContext.dll + + + + packages\System.Console.4.3.0\lib\net46\System.Console.dll + + + packages\System.Diagnostics.DiagnosticSource.4.3.0\lib\net46\System.Diagnostics.DiagnosticSource.dll + + + packages\System.Diagnostics.Tracing.4.3.0\lib\net462\System.Diagnostics.Tracing.dll + + + packages\System.Globalization.Calendars.4.3.0\lib\net46\System.Globalization.Calendars.dll + + + packages\System.IO.4.3.0\lib\net462\System.IO.dll + + + packages\System.IO.Compression.4.3.0\lib\net46\System.IO.Compression.dll + + + packages\System.IO.Compression.ZipFile.4.3.0\lib\net46\System.IO.Compression.ZipFile.dll + + + packages\System.IO.FileSystem.4.3.0\lib\net46\System.IO.FileSystem.dll + + + packages\System.IO.FileSystem.Primitives.4.3.0\lib\net46\System.IO.FileSystem.Primitives.dll + + + packages\System.Linq.4.3.0\lib\net463\System.Linq.dll + + + packages\System.Linq.Expressions.4.3.0\lib\net463\System.Linq.Expressions.dll + + + packages\System.Net.Http.4.3.0\lib\net46\System.Net.Http.dll + + + packages\System.Net.Sockets.4.3.0\lib\net46\System.Net.Sockets.dll + + + + packages\System.Reflection.4.3.0\lib\net462\System.Reflection.dll + + + packages\System.Runtime.4.3.0\lib\net462\System.Runtime.dll + + + packages\System.Runtime.Extensions.4.3.0\lib\net462\System.Runtime.Extensions.dll + + + packages\System.Runtime.InteropServices.4.3.0\lib\net463\System.Runtime.InteropServices.dll + + + packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll + + + packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net463\System.Security.Cryptography.Algorithms.dll + + + packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll + + + packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll + + + packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll + + + packages\System.Text.RegularExpressions.4.3.0\lib\net463\System.Text.RegularExpressions.dll + - + + packages\System.Xml.ReaderWriter.4.3.0\lib\net46\System.Xml.ReaderWriter.dll + @@ -60,6 +147,7 @@ + DownloadForm.cs @@ -75,6 +163,7 @@ favicon.ico + SettingsSingleFileGenerator Settings.Designer.cs @@ -88,5 +177,18 @@ + + + + + + + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105.The missing file is {0}. + + + + + + \ No newline at end of file diff --git a/extra/exe-builder/Version.cs b/extra/exe-builder/Version.cs new file mode 100644 index 00000000..896c7a24 --- /dev/null +++ b/extra/exe-builder/Version.cs @@ -0,0 +1,9 @@ +namespace UptimeKuma { + public class Version { + public string latest { get; set; } + public string slow { get; set; } + public string beta { get; set; } + public string nodejs { get; set; } + public string exe { get; set; } + } +} diff --git a/extra/exe-builder/packages.config b/extra/exe-builder/packages.config new file mode 100644 index 00000000..82dd7c3b --- /dev/null +++ b/extra/exe-builder/packages.config @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file