NET Core and some improvements (Build scripts will need to be updated)
This commit is contained in:
parent
3adf64eda4
commit
fb17b6daa8
8
.idea/.idea.UpTool2/.idea/modules.xml
Normal file
8
.idea/.idea.UpTool2/.idea/modules.xml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/.idea.UpTool2/riderModule.iml" filepath="$PROJECT_DIR$/.idea/.idea.UpTool2/riderModule.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
7
.idea/.idea.UpTool2/riderModule.iml
Normal file
7
.idea/.idea.UpTool2/riderModule.iml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="RIDER_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$/../.." />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
@ -1,11 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
|
||||||
using System.IO.Compression;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.CommandLine;
|
using System.CommandLine;
|
||||||
using System.CommandLine.Invocation;
|
using System.CommandLine.Invocation;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.IO.Compression;
|
||||||
|
using System.Reflection;
|
||||||
|
using CC_Functions.Misc;
|
||||||
|
|
||||||
namespace UpTool_build_tool
|
namespace UpTool_build_tool
|
||||||
{
|
{
|
||||||
@ -18,15 +18,15 @@ namespace UpTool_build_tool
|
|||||||
build.AddOption(new Option<string>("--binDir", "Directory to package"));
|
build.AddOption(new Option<string>("--binDir", "Directory to package"));
|
||||||
build.AddOption(new Option<string>("--mainBin", "The applications main binary"));
|
build.AddOption(new Option<string>("--mainBin", "The applications main binary"));
|
||||||
build.AddOption(new Option<string>("--packageFile", "Directory to package"));
|
build.AddOption(new Option<string>("--packageFile", "Directory to package"));
|
||||||
build.AddOption(new Option<string>("--tempPath", Path.GetTempPath, "Directory to package"));
|
build.AddOption(new Option<bool>("--noShortcuts",
|
||||||
build.AddOption(new Option<bool>("--noShortcuts", "When this is enabled the scripts will not generate a start-menu item"));
|
"When this is enabled the scripts will not generate a start-menu item"));
|
||||||
build.AddOption(new Option<bool>("--noLogo", "Disables the logo"));
|
build.AddOption(new Option<bool>("--noLogo", "Disables the logo"));
|
||||||
build.Handler = CommandHandler.Create<string, string, string, string, bool, bool>(Build);
|
build.Handler = CommandHandler.Create<string, string, string, bool, bool>(Build);
|
||||||
rootCommand.AddCommand(build);
|
rootCommand.AddCommand(build);
|
||||||
return rootCommand.InvokeAsync(args).Result;
|
return rootCommand.InvokeAsync(args).Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void Build(string binDir, string mainBin, string packageFile, string tempPath, bool noLogo, bool noShortcuts)
|
private static void Build(string binDir, string mainBin, string packageFile, bool noLogo, bool noShortcuts)
|
||||||
{
|
{
|
||||||
Stopwatch watch = Stopwatch.StartNew();
|
Stopwatch watch = Stopwatch.StartNew();
|
||||||
if (!noLogo)
|
if (!noLogo)
|
||||||
@ -40,22 +40,15 @@ namespace UpTool_build_tool
|
|||||||
}
|
}
|
||||||
Console.WriteLine("Parsing arguments...");
|
Console.WriteLine("Parsing arguments...");
|
||||||
packageFile ??= Path.Combine(binDir, "package.zip");
|
packageFile ??= Path.Combine(binDir, "package.zip");
|
||||||
tempPath = Path.Combine(tempPath, "UpTool2Pkg");
|
|
||||||
Console.WriteLine("Removing previous files...");
|
|
||||||
if (File.Exists(packageFile))
|
if (File.Exists(packageFile))
|
||||||
|
{
|
||||||
|
Console.WriteLine("Removing previous package...");
|
||||||
File.Delete(packageFile);
|
File.Delete(packageFile);
|
||||||
if (Directory.Exists(tempPath))
|
}
|
||||||
Directory.Delete(tempPath, true);
|
|
||||||
Directory.CreateDirectory(tempPath);
|
|
||||||
Console.WriteLine("Copying binary dir...");
|
Console.WriteLine("Copying binary dir...");
|
||||||
ZipFile.CreateFromDirectory(binDir, Path.Combine(tempPath, "dataDir.zip"));
|
using ZipArchive archive = ZipFile.Open(packageFile, ZipArchiveMode.Create);
|
||||||
Directory.CreateDirectory(Path.Combine(tempPath, "Data"));
|
{
|
||||||
ZipFile.ExtractToDirectory(Path.Combine(tempPath, "dataDir.zip"), Path.Combine(tempPath, "Data"));
|
archive.AddDirectory(binDir, "Data", new[] {".xml", ".pdb"}, new[] {packageFile});
|
||||||
File.Delete(Path.Combine(tempPath, "dataDir.zip"));
|
|
||||||
Console.WriteLine("Cleaning up .xml and .pdb files...");
|
|
||||||
Directory.GetFiles(Path.Combine(tempPath, "Data"))
|
|
||||||
.Where(s => new[] { ".xml", ".pdb" }.Contains(Path.GetExtension(s)))
|
|
||||||
.ToList().ForEach(File.Delete);
|
|
||||||
Console.WriteLine("Creating batch scripts...");
|
Console.WriteLine("Creating batch scripts...");
|
||||||
string installBat = "@echo off\r\necho INSTALL";
|
string installBat = "@echo off\r\necho INSTALL";
|
||||||
string removeBat = "@echo off\r\necho REMOVE";
|
string removeBat = "@echo off\r\necho REMOVE";
|
||||||
@ -66,14 +59,17 @@ namespace UpTool_build_tool
|
|||||||
mainBin = Directory.GetFiles(binDir, "*.exe")[0];
|
mainBin = Directory.GetFiles(binDir, "*.exe")[0];
|
||||||
if (tmp.Length > 1)
|
if (tmp.Length > 1)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Detected multiple EXEs. This is not recommended as all processes running in the app folder will need to be terminated for uninstall to succeed");
|
Console.WriteLine(
|
||||||
Console.WriteLine("Please consider removing unnecessary EXEs or notify me that anyone is actually using this.");
|
"Detected multiple EXEs. This is not recommended as all processes running in the app folder will need to be terminated for uninstall to succeed");
|
||||||
|
Console.WriteLine(
|
||||||
|
"Please consider removing unnecessary EXEs or notify me that anyone is actually using this.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!noShortcuts)
|
if (!noShortcuts)
|
||||||
{
|
{
|
||||||
installBat += "\r\n";
|
installBat += "\r\n";
|
||||||
installBat += @"powershell ""$s=(New-Object -COM WScript.Shell).CreateShortcut('%appdata%\Microsoft\Windows\Start Menu\Programs\{programName}.lnk');$s.TargetPath='%cd%\{programName}.exe';$s.Save()""";
|
installBat +=
|
||||||
|
@"powershell ""$s=(New-Object -COM WScript.Shell).CreateShortcut('%appdata%\Microsoft\Windows\Start Menu\Programs\{programName}.lnk');$s.TargetPath='%cd%\{programName}.exe';$s.Save()""";
|
||||||
removeBat += "\r\n";
|
removeBat += "\r\n";
|
||||||
removeBat += @"del ""%appdata%\Microsoft\Windows\Start Menu\Programs\{programName}.lnk""";
|
removeBat += @"del ""%appdata%\Microsoft\Windows\Start Menu\Programs\{programName}.lnk""";
|
||||||
}
|
}
|
||||||
@ -84,12 +80,17 @@ namespace UpTool_build_tool
|
|||||||
}
|
}
|
||||||
installBat += "\r\ntimeout /t 1";
|
installBat += "\r\ntimeout /t 1";
|
||||||
removeBat += "\r\ntimeout /t 1";
|
removeBat += "\r\ntimeout /t 1";
|
||||||
File.WriteAllText(Path.Combine(tempPath, "Install.bat"), installBat);
|
using (Stream s = archive.CreateEntry("Install.bat").Open())
|
||||||
File.WriteAllText(Path.Combine(tempPath, "Remove.bat"), removeBat);
|
{
|
||||||
Console.WriteLine("Packaging...");
|
using StreamWriter writer = new StreamWriter(s);
|
||||||
ZipFile.CreateFromDirectory(tempPath, packageFile);
|
writer.Write(installBat);
|
||||||
Console.WriteLine("Cleaning up temp path...");
|
}
|
||||||
Directory.Delete(tempPath, true);
|
using (Stream s = archive.CreateEntry("Remove.bat").Open())
|
||||||
|
{
|
||||||
|
using StreamWriter writer = new StreamWriter(s);
|
||||||
|
writer.Write(removeBat);
|
||||||
|
}
|
||||||
|
}
|
||||||
watch.Stop();
|
watch.Stop();
|
||||||
Console.WriteLine($"Completed package creation in {watch.Elapsed}");
|
Console.WriteLine($"Completed package creation in {watch.Elapsed}");
|
||||||
Console.WriteLine($"Output file: {Path.GetFullPath(packageFile)}");
|
Console.WriteLine($"Output file: {Path.GetFullPath(packageFile)}");
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
<PostBuildEvent>.\pkgtool.exe build --noLogo --noShortcuts --binDir .</PostBuildEvent>
|
<PostBuildEvent>.\pkgtool.exe build --noLogo --noShortcuts --binDir .</PostBuildEvent>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="CC-Functions.Misc" Version="1.0.7.1" />
|
||||||
<PackageReference Include="System.CommandLine" Version="2.0.0-beta1.20104.2" />
|
<PackageReference Include="System.CommandLine" Version="2.0.0-beta1.20104.2" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
68
UpTool2/AppNameDialog.Designer.cs
generated
Normal file
68
UpTool2/AppNameDialog.Designer.cs
generated
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace UpTool2
|
||||||
|
{
|
||||||
|
partial class AppNameDialog
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.nameBox = new System.Windows.Forms.TextBox();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// textBox1
|
||||||
|
//
|
||||||
|
this.nameBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Left)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.nameBox.Location = new System.Drawing.Point(12, 12);
|
||||||
|
this.nameBox.Name = "textBox1";
|
||||||
|
this.nameBox.Size = new System.Drawing.Size(375, 23);
|
||||||
|
this.nameBox.TabIndex = 0;
|
||||||
|
this.nameBox.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
|
||||||
|
//
|
||||||
|
// AppNameDialog
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(399, 41);
|
||||||
|
this.Controls.Add(this.nameBox);
|
||||||
|
this.Name = "AppNameDialog";
|
||||||
|
this.ShowIcon = false;
|
||||||
|
this.ShowInTaskbar = false;
|
||||||
|
this.Text = "App Name";
|
||||||
|
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.AppNameDialog_FormClosing);
|
||||||
|
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.AppNameDialog_FormClosed);
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.TextBox nameBox;
|
||||||
|
}
|
||||||
|
}
|
25
UpTool2/AppNameDialog.cs
Normal file
25
UpTool2/AppNameDialog.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using System;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace UpTool2
|
||||||
|
{
|
||||||
|
internal partial class AppNameDialog : Form
|
||||||
|
{
|
||||||
|
public string name;
|
||||||
|
|
||||||
|
private AppNameDialog() => InitializeComponent();
|
||||||
|
|
||||||
|
public static string Show()
|
||||||
|
{
|
||||||
|
using AppNameDialog dialog = new AppNameDialog();
|
||||||
|
dialog.ShowDialog();
|
||||||
|
return dialog.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AppNameDialog_FormClosed(object sender, FormClosedEventArgs e) => name = nameBox.Text;
|
||||||
|
|
||||||
|
private void AppNameDialog_FormClosing(object sender, FormClosingEventArgs e) => name = nameBox.Text;
|
||||||
|
|
||||||
|
private void textBox1_TextChanged(object sender, EventArgs e) => name = nameBox.Text;
|
||||||
|
}
|
||||||
|
}
|
61
UpTool2/AppNameDialog.resx
Normal file
61
UpTool2/AppNameDialog.resx
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
@ -6,13 +6,13 @@ using System.IO.Compression;
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using Microsoft.VisualBasic;
|
|
||||||
using UpTool2.DataStructures;
|
using UpTool2.DataStructures;
|
||||||
using UpTool2.Properties;
|
using UpTool2.Properties;
|
||||||
using UpTool2.Tool;
|
using UpTool2.Tool;
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace UpTool2
|
namespace UpTool2
|
||||||
@ -91,13 +91,14 @@ namespace UpTool2
|
|||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
if (searchPackageDialog.ShowDialog() != DialogResult.OK)
|
if (searchPackageDialog.ShowDialog() != DialogResult.OK)
|
||||||
return;
|
return;
|
||||||
Guid id = Guid.NewGuid();
|
Guid id = Guid.NewGuid();
|
||||||
while (GlobalVariables.Apps.ContainsKey(id) || Directory.Exists(PathTool.GetAppPath(id)))
|
while (GlobalVariables.Apps.ContainsKey(id) || Directory.Exists(PathTool.GetAppPath(id)))
|
||||||
id = Guid.NewGuid();
|
id = Guid.NewGuid();
|
||||||
App appI = new App(Interaction.InputBox("Name:"), "Locally installed package, removal only",
|
App appI = new App(AppNameDialog.Show(), "Locally installed package, removal only",
|
||||||
GlobalVariables.minimumVer, "", true, "", id, Color.Red, Resources.C_64.ToBitmap(), false, "");
|
GlobalVariables.minimumVer, "", true, "", id, Color.Red, Resources.C_64.ToBitmap(), false, "");
|
||||||
AppInstall.InstallZip(searchPackageDialog.FileName, appI);
|
AppInstall.InstallZip(searchPackageDialog.FileName, appI);
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
@ -184,7 +185,7 @@ namespace UpTool2
|
|||||||
}
|
}
|
||||||
catch (Exception e1)
|
catch (Exception e1)
|
||||||
{
|
{
|
||||||
MessageBox.Show(e1.ToString()
|
MessageBox.Show(e1
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
+ $"{Environment.NewLine}File was: {path}"
|
+ $"{Environment.NewLine}File was: {path}"
|
||||||
#endif
|
#endif
|
||||||
|
@ -7,14 +7,13 @@ using System.Linq;
|
|||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Security.AccessControl;
|
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Security.Principal;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using UpTool2.Tool;
|
using UpTool2.Tool;
|
||||||
|
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
using Shortcut = UpTool2.Tool.Shortcut;
|
using Shortcut = UpTool2.Tool.Shortcut;
|
||||||
#endif
|
#endif
|
||||||
@ -32,15 +31,9 @@ namespace UpTool2
|
|||||||
Application.EnableVisualStyles();
|
Application.EnableVisualStyles();
|
||||||
Application.SetCompatibleTextRenderingDefault(false);
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
ShowSplash();
|
ShowSplash();
|
||||||
string appGuid = ((GuidAttribute) Assembly.GetExecutingAssembly()
|
using Mutex mutex = new Mutex(false,
|
||||||
.GetCustomAttributes(typeof(GuidAttribute), false).GetValue(0)).Value;
|
$"Global\\{{{((GuidAttribute) Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(GuidAttribute), false).GetValue(0)).Value}}}",
|
||||||
string mutexId = string.Format("Global\\{{{0}}}", appGuid);
|
out bool _);
|
||||||
MutexAccessRule allowEveryoneRule = new MutexAccessRule(
|
|
||||||
new SecurityIdentifier(WellKnownSidType.WorldSid, null), MutexRights.FullControl,
|
|
||||||
AccessControlType.Allow);
|
|
||||||
MutexSecurity securitySettings = new MutexSecurity();
|
|
||||||
securitySettings.AddAccessRule(allowEveryoneRule);
|
|
||||||
using Mutex mutex = new Mutex(false, mutexId, out bool createdNew, securitySettings);
|
|
||||||
bool hasHandle = false;
|
bool hasHandle = false;
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
try
|
try
|
||||||
@ -50,7 +43,12 @@ namespace UpTool2
|
|||||||
{
|
{
|
||||||
hasHandle = mutex.WaitOne(5000, false);
|
hasHandle = mutex.WaitOne(5000, false);
|
||||||
if (hasHandle == false)
|
if (hasHandle == false)
|
||||||
throw new TimeoutException("Timeout waiting for exclusive access");
|
{
|
||||||
|
Process[] processes = Process.GetProcessesByName("UpTool2");
|
||||||
|
if (processes.Length > 0)
|
||||||
|
WindowHelper.BringProcessToFront(Process.GetProcessesByName("UpTool2")[0]);
|
||||||
|
Environment.Exit(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (AbandonedMutexException)
|
catch (AbandonedMutexException)
|
||||||
{
|
{
|
||||||
@ -77,12 +75,15 @@ Do you want to continue?", "UpTool2", MessageBoxButtons.YesNo) != DialogResult.Y
|
|||||||
throw new Exception("Exiting...");
|
throw new Exception("Exiting...");
|
||||||
MessageBox.Show("Installing an Update. Please restart from your start menu!");
|
MessageBox.Show("Installing an Update. Please restart from your start menu!");
|
||||||
InstallUpdate(XDocument.Load(metaXml).Element("meta"));
|
InstallUpdate(XDocument.Load(metaXml).Element("meta"));
|
||||||
Shortcut.Make(PathTool.GetRelative("Install", "UpTool2.exe"), Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Programs), "UpTool2.lnk"));
|
Shortcut.Make(PathTool.GetRelative("Install", "UpTool2.exe"),
|
||||||
|
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Programs), "UpTool2.lnk"));
|
||||||
mutex.ReleaseMutex();
|
mutex.ReleaseMutex();
|
||||||
Environment.Exit(0);
|
Environment.Exit(0);
|
||||||
}
|
}
|
||||||
if (!File.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Programs), "UpTool2.lnk")))
|
if (!File.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Programs),
|
||||||
Shortcut.Make(PathTool.GetRelative("Install", "UpTool2.exe"), Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Programs), "UpTool2.lnk"));
|
"UpTool2.lnk")))
|
||||||
|
Shortcut.Make(PathTool.GetRelative("Install", "UpTool2.exe"),
|
||||||
|
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Programs), "UpTool2.lnk"));
|
||||||
#endif
|
#endif
|
||||||
if (!Directory.Exists(PathTool.GetRelative("Apps")))
|
if (!Directory.Exists(PathTool.GetRelative("Apps")))
|
||||||
Directory.CreateDirectory(PathTool.GetRelative("Apps"));
|
Directory.CreateDirectory(PathTool.GetRelative("Apps"));
|
||||||
@ -210,8 +211,8 @@ Do you want to continue?", "UpTool2", MessageBoxButtons.YesNo) != DialogResult.Y
|
|||||||
Directory.Delete(PathTool.GetRelative("Install", "tmp"), true);
|
Directory.Delete(PathTool.GetRelative("Install", "tmp"), true);
|
||||||
Directory.CreateDirectory(PathTool.GetRelative("Install", "tmp"));
|
Directory.CreateDirectory(PathTool.GetRelative("Install", "tmp"));
|
||||||
using (MemoryStream ms = new MemoryStream(dl))
|
using (MemoryStream ms = new MemoryStream(dl))
|
||||||
using (ZipArchive ar = new ZipArchive(ms))
|
|
||||||
{
|
{
|
||||||
|
using ZipArchive ar = new ZipArchive(ms);
|
||||||
ar.Entries.Where(s => !string.IsNullOrEmpty(s.Name)).ToList().ForEach(s =>
|
ar.Entries.Where(s => !string.IsNullOrEmpty(s.Name)).ToList().ForEach(s =>
|
||||||
{
|
{
|
||||||
s.ExtractToFile(PathTool.GetRelative("Install", "tmp", s.Name), true);
|
s.ExtractToFile(PathTool.GetRelative("Install", "tmp", s.Name), true);
|
||||||
@ -231,8 +232,7 @@ Do you want to continue?", "UpTool2", MessageBoxButtons.YesNo) != DialogResult.Y
|
|||||||
{
|
{
|
||||||
HttpWebRequest request = (HttpWebRequest) WebRequest.Create(url);
|
HttpWebRequest request = (HttpWebRequest) WebRequest.Create(url);
|
||||||
request.Timeout = 3000;
|
request.Timeout = 3000;
|
||||||
request.AllowAutoRedirect = false;
|
request.AllowAutoRedirect = true;
|
||||||
request.Method = "HEAD";
|
|
||||||
using WebResponse response = request.GetResponse();
|
using WebResponse response = request.GetResponse();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -87,6 +87,9 @@ Online: {appI.Hash.ToUpper()}");
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Use
|
||||||
|
//PowerShell -Command "Add-Type -AssemblyName PresentationFramework;[System.Windows.MessageBox]::Show('Hello World')"
|
||||||
|
//for message boxes
|
||||||
private static void CompleteInstall(App app) =>
|
private static void CompleteInstall(App app) =>
|
||||||
CompleteInstall(app.appPath, app.Name, app.Description, app.Version, app.MainFile);
|
CompleteInstall(app.appPath, app.Name, app.Description, app.Version, app.MainFile);
|
||||||
|
|
||||||
|
@ -37,7 +37,8 @@ namespace UpTool2.Tool
|
|||||||
XElement[] tmp_apparray = repo.Element("repo").Elements("app").Where(app =>
|
XElement[] tmp_apparray = repo.Element("repo").Elements("app").Where(app =>
|
||||||
!tmpAppsList.Any(a => a.Element("ID").Value == app.Element("ID").Value) ||
|
!tmpAppsList.Any(a => a.Element("ID").Value == app.Element("ID").Value) ||
|
||||||
!tmpAppsList
|
!tmpAppsList
|
||||||
.Where(a => a.Element("ID").Value == app.Element("ID").Value).Any(a => GetVer(a.Element("Version")) >= app.Element("Version").GetVer())).ToArray()
|
.Where(a => a.Element("ID").Value == app.Element("ID").Value).Any(a =>
|
||||||
|
GetVer(a.Element("Version")) >= app.Element("Version").GetVer())).ToArray()
|
||||||
.Concat(repo.Element("repo").Elements("applink")
|
.Concat(repo.Element("repo").Elements("applink")
|
||||||
.Select(s => XDocument.Load(s.Value).Element("app"))).ToArray();
|
.Select(s => XDocument.Load(s.Value).Element("app"))).ToArray();
|
||||||
for (int i1 = 0; i1 < tmp_apparray.Length; i1++)
|
for (int i1 = 0; i1 < tmp_apparray.Length; i1++)
|
||||||
@ -99,7 +100,8 @@ namespace UpTool2.Tool
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tmpAppsList.Sort((x, y) => string.Compare(x.Element("Name").Value, y.Element("Name").Value, StringComparison.Ordinal));
|
tmpAppsList.Sort((x, y) =>
|
||||||
|
string.Compare(x.Element("Name").Value, y.Element("Name").Value, StringComparison.Ordinal));
|
||||||
if (meta.Element("LocalRepo") == null)
|
if (meta.Element("LocalRepo") == null)
|
||||||
meta.Add(new XElement("LocalRepo"));
|
meta.Add(new XElement("LocalRepo"));
|
||||||
XElement repos = meta.Element("LocalRepo");
|
XElement repos = meta.Element("LocalRepo");
|
||||||
@ -146,7 +148,8 @@ namespace UpTool2.Tool
|
|||||||
#endif
|
#endif
|
||||||
});
|
});
|
||||||
Directory.GetDirectories(PathTool.appsPath)
|
Directory.GetDirectories(PathTool.appsPath)
|
||||||
.Where(s => Guid.TryParse(Path.GetFileName(s), out Guid guid) && !GlobalVariables.Apps.ContainsKey(guid)).ToList().ForEach(s =>
|
.Where(s => Guid.TryParse(Path.GetFileName(s), out Guid guid) &&
|
||||||
|
!GlobalVariables.Apps.ContainsKey(guid)).ToList().ForEach(s =>
|
||||||
{
|
{
|
||||||
Guid tmp = Guid.Parse(Path.GetFileName(s));
|
Guid tmp = Guid.Parse(Path.GetFileName(s));
|
||||||
try
|
try
|
||||||
|
@ -1,115 +1,23 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
|
||||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
|
||||||
<ProjectGuid>{C0C1E002-9E13-4E8F-A035-DBDC5128E00E}</ProjectGuid>
|
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<RootNamespace>UpTool2</RootNamespace>
|
|
||||||
<AssemblyName>UpTool2</AssemblyName>
|
|
||||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
|
||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
<FileAlignment>512</FileAlignment>
|
|
||||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
|
||||||
<Deterministic>false</Deterministic>
|
<Deterministic>false</Deterministic>
|
||||||
<TargetFrameworkProfile />
|
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
|
||||||
<DebugSymbols>true</DebugSymbols>
|
|
||||||
<DebugType>full</DebugType>
|
|
||||||
<Optimize>false</Optimize>
|
|
||||||
<OutputPath>bin\Debug\</OutputPath>
|
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
|
||||||
<ErrorReport>prompt</ErrorReport>
|
|
||||||
<WarningLevel>4</WarningLevel>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
|
||||||
<DebugType>none</DebugType>
|
<DebugType>none</DebugType>
|
||||||
<Optimize>true</Optimize>
|
|
||||||
<OutputPath>bin\Release\</OutputPath>
|
|
||||||
<DefineConstants>TRACE</DefineConstants>
|
|
||||||
<ErrorReport>prompt</ErrorReport>
|
|
||||||
<WarningLevel>4</WarningLevel>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<StartupObject>UpTool2.Program</StartupObject>
|
<StartupObject>UpTool2.Program</StartupObject>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
|
||||||
<Reference Include="Microsoft.VisualBasic" />
|
|
||||||
<Reference Include="System" />
|
|
||||||
<Reference Include="System.Core" />
|
|
||||||
<Reference Include="System.IO.Compression" />
|
|
||||||
<Reference Include="System.IO.Compression.FileSystem" />
|
|
||||||
<Reference Include="System.Xml.Linq" />
|
|
||||||
<Reference Include="System.Data.DataSetExtensions" />
|
|
||||||
<Reference Include="Microsoft.CSharp" />
|
|
||||||
<Reference Include="System.Data" />
|
|
||||||
<Reference Include="System.Deployment" />
|
|
||||||
<Reference Include="System.Drawing" />
|
|
||||||
<Reference Include="System.Net.Http" />
|
|
||||||
<Reference Include="System.Windows.Forms" />
|
|
||||||
<Reference Include="System.Xml" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Include="DataStructures\App.cs" />
|
|
||||||
<Compile Include="Tool\AppInstall.cs" />
|
|
||||||
<Compile Include="Tool\DownloadDialog.cs">
|
|
||||||
<SubType>Form</SubType>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="Tool\DownloadDialog.Designer.cs">
|
|
||||||
<DependentUpon>DownloadDialog.cs</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="GlobalVariables.cs" />
|
|
||||||
<Compile Include="MainForm.cs">
|
|
||||||
<SubType>Form</SubType>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="MainForm.Designer.cs">
|
|
||||||
<DependentUpon>MainForm.cs</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="Program.cs" />
|
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
|
||||||
<Compile Include="Tool\PathTool.cs" />
|
|
||||||
<Compile Include="Tool\RepoManagement.cs" />
|
|
||||||
<Compile Include="Tool\Shortcut.cs" />
|
|
||||||
<Compile Include="SourcesForm.cs">
|
|
||||||
<SubType>Form</SubType>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="SourcesForm.Designer.cs">
|
|
||||||
<DependentUpon>SourcesForm.cs</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="DataStructures\Status.cs" />
|
|
||||||
<EmbeddedResource Include="Tool\DownloadDialog.resx">
|
|
||||||
<DependentUpon>DownloadDialog.cs</DependentUpon>
|
|
||||||
</EmbeddedResource>
|
|
||||||
<EmbeddedResource Include="MainForm.resx">
|
|
||||||
<DependentUpon>MainForm.cs</DependentUpon>
|
|
||||||
</EmbeddedResource>
|
|
||||||
<EmbeddedResource Include="Properties\Resources.resx">
|
|
||||||
<Generator>ResXFileCodeGenerator</Generator>
|
|
||||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
|
||||||
<SubType>Designer</SubType>
|
|
||||||
</EmbeddedResource>
|
|
||||||
<Compile Include="Properties\Resources.Designer.cs">
|
|
||||||
<AutoGen>True</AutoGen>
|
|
||||||
<DependentUpon>Resources.resx</DependentUpon>
|
|
||||||
<DesignTime>True</DesignTime>
|
|
||||||
</Compile>
|
|
||||||
<EmbeddedResource Include="SourcesForm.resx">
|
|
||||||
<DependentUpon>SourcesForm.cs</DependentUpon>
|
|
||||||
</EmbeddedResource>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<None Include="App.config" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
|
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="Resources\C_64.ico" />
|
<PackageReference Include="CC-Functions.Misc" Version="1.0.7.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
|
||||||
</Project>
|
</Project>
|
27
UpTool2/WindowHelper.cs
Normal file
27
UpTool2/WindowHelper.cs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace UpTool2
|
||||||
|
{
|
||||||
|
//TODO: This class is Windows-only and can't be used cross-platform.
|
||||||
|
public static class WindowHelper
|
||||||
|
{
|
||||||
|
public static void BringProcessToFront(Process process)
|
||||||
|
{
|
||||||
|
IntPtr handle = process.MainWindowHandle;
|
||||||
|
if (IsIconic(handle))
|
||||||
|
ShowWindow(handle, 9);
|
||||||
|
SetForegroundWindow(handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport("User32.dll")]
|
||||||
|
private static extern bool SetForegroundWindow(IntPtr handle);
|
||||||
|
|
||||||
|
[DllImport("User32.dll")]
|
||||||
|
private static extern bool ShowWindow(IntPtr handle, int nCmdShow);
|
||||||
|
|
||||||
|
[DllImport("User32.dll")]
|
||||||
|
private static extern bool IsIconic(IntPtr handle);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user