NET Core and some improvements (Build scripts will need to be updated)

This commit is contained in:
CreepyCrafter24 2020-03-13 20:16:33 +01:00
parent 3adf64eda4
commit fb17b6daa8
13 changed files with 313 additions and 200 deletions

View 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>

View 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>

View File

@ -1,11 +1,11 @@
using System;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.CommandLine;
using System.CommandLine.Invocation;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Reflection;
using CC_Functions.Misc;
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>("--mainBin", "The applications main binary"));
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", "When this is enabled the scripts will not generate a start-menu item"));
build.AddOption(new Option<bool>("--noShortcuts",
"When this is enabled the scripts will not generate a start-menu item"));
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);
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();
if (!noLogo)
@ -40,56 +40,57 @@ namespace UpTool_build_tool
}
Console.WriteLine("Parsing arguments...");
packageFile ??= Path.Combine(binDir, "package.zip");
tempPath = Path.Combine(tempPath, "UpTool2Pkg");
Console.WriteLine("Removing previous files...");
if (File.Exists(packageFile))
File.Delete(packageFile);
if (Directory.Exists(tempPath))
Directory.Delete(tempPath, true);
Directory.CreateDirectory(tempPath);
Console.WriteLine("Copying binary dir...");
ZipFile.CreateFromDirectory(binDir, Path.Combine(tempPath, "dataDir.zip"));
Directory.CreateDirectory(Path.Combine(tempPath, "Data"));
ZipFile.ExtractToDirectory(Path.Combine(tempPath, "dataDir.zip"), Path.Combine(tempPath, "Data"));
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...");
string installBat = "@echo off\r\necho INSTALL";
string removeBat = "@echo off\r\necho REMOVE";
if (string.IsNullOrWhiteSpace(mainBin))
{
string[] tmp = Directory.GetFiles(binDir, "*.exe");
if (tmp.Length > 0)
mainBin = Directory.GetFiles(binDir, "*.exe")[0];
if (tmp.Length > 1)
Console.WriteLine("Removing previous package...");
File.Delete(packageFile);
}
Console.WriteLine("Copying binary dir...");
using ZipArchive archive = ZipFile.Open(packageFile, ZipArchiveMode.Create);
{
archive.AddDirectory(binDir, "Data", new[] {".xml", ".pdb"}, new[] {packageFile});
Console.WriteLine("Creating batch scripts...");
string installBat = "@echo off\r\necho INSTALL";
string removeBat = "@echo off\r\necho REMOVE";
if (string.IsNullOrWhiteSpace(mainBin))
{
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("Please consider removing unnecessary EXEs or notify me that anyone is actually using this.");
string[] tmp = Directory.GetFiles(binDir, "*.exe");
if (tmp.Length > 0)
mainBin = Directory.GetFiles(binDir, "*.exe")[0];
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(
"Please consider removing unnecessary EXEs or notify me that anyone is actually using this.");
}
}
if (!noShortcuts)
{
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()""";
removeBat += "\r\n";
removeBat += @"del ""%appdata%\Microsoft\Windows\Start Menu\Programs\{programName}.lnk""";
}
if (!string.IsNullOrWhiteSpace(mainBin))
{
removeBat += "\r\n";
removeBat += $@"taskkill /f /im ""{Path.GetFileNameWithoutExtension(mainBin)}.exe""";
}
installBat += "\r\ntimeout /t 1";
removeBat += "\r\ntimeout /t 1";
using (Stream s = archive.CreateEntry("Install.bat").Open())
{
using StreamWriter writer = new StreamWriter(s);
writer.Write(installBat);
}
using (Stream s = archive.CreateEntry("Remove.bat").Open())
{
using StreamWriter writer = new StreamWriter(s);
writer.Write(removeBat);
}
}
if (!noShortcuts)
{
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()""";
removeBat += "\r\n";
removeBat += @"del ""%appdata%\Microsoft\Windows\Start Menu\Programs\{programName}.lnk""";
}
if (!string.IsNullOrWhiteSpace(mainBin))
{
removeBat += "\r\n";
removeBat += $@"taskkill /f /im ""{Path.GetFileNameWithoutExtension(mainBin)}.exe""";
}
installBat += "\r\ntimeout /t 1";
removeBat += "\r\ntimeout /t 1";
File.WriteAllText(Path.Combine(tempPath, "Install.bat"), installBat);
File.WriteAllText(Path.Combine(tempPath, "Remove.bat"), removeBat);
Console.WriteLine("Packaging...");
ZipFile.CreateFromDirectory(tempPath, packageFile);
Console.WriteLine("Cleaning up temp path...");
Directory.Delete(tempPath, true);
watch.Stop();
Console.WriteLine($"Completed package creation in {watch.Elapsed}");
Console.WriteLine($"Output file: {Path.GetFullPath(packageFile)}");

View File

@ -13,6 +13,7 @@
<PostBuildEvent>.\pkgtool.exe build --noLogo --noShortcuts --binDir .</PostBuildEvent>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="CC-Functions.Misc" Version="1.0.7.1" />
<PackageReference Include="System.CommandLine" Version="2.0.0-beta1.20104.2" />
</ItemGroup>
</Project>

68
UpTool2/AppNameDialog.Designer.cs generated Normal file
View 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
View 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;
}
}

View 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>

View File

@ -6,13 +6,13 @@ using System.IO.Compression;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using Microsoft.VisualBasic;
using UpTool2.DataStructures;
using UpTool2.Properties;
using UpTool2.Tool;
#if DEBUG
using System.Threading;
using System.Linq;
#endif
namespace UpTool2
@ -91,13 +91,14 @@ namespace UpTool2
#if !DEBUG
try
{
#endif
if (searchPackageDialog.ShowDialog() != DialogResult.OK)
return;
Guid id = Guid.NewGuid();
while (GlobalVariables.Apps.ContainsKey(id) || Directory.Exists(PathTool.GetAppPath(id)))
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, "");
AppInstall.InstallZip(searchPackageDialog.FileName, appI);
#if !DEBUG
@ -184,10 +185,10 @@ namespace UpTool2
}
catch (Exception e1)
{
MessageBox.Show(e1.ToString()
#if DEBUG
+ $"{Environment.NewLine}File was: {path}"
#endif
MessageBox.Show(e1
#if DEBUG
+ $"{Environment.NewLine}File was: {path}"
#endif
, "Failed to start!");
}
}

View File

@ -7,14 +7,13 @@ using System.Linq;
using System.Net;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Security.AccessControl;
using System.Security.Cryptography;
using System.Security.Principal;
using System.Threading;
using System.Windows.Forms;
using System.Xml;
using System.Xml.Linq;
using UpTool2.Tool;
#if !DEBUG
using Shortcut = UpTool2.Tool.Shortcut;
#endif
@ -32,25 +31,24 @@ namespace UpTool2
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
ShowSplash();
string appGuid = ((GuidAttribute) Assembly.GetExecutingAssembly()
.GetCustomAttributes(typeof(GuidAttribute), false).GetValue(0)).Value;
string mutexId = string.Format("Global\\{{{0}}}", appGuid);
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);
using Mutex mutex = new Mutex(false,
$"Global\\{{{((GuidAttribute) Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(GuidAttribute), false).GetValue(0)).Value}}}",
out bool _);
bool hasHandle = false;
#if !DEBUG
try
{
try
{
#endif
try
{
hasHandle = mutex.WaitOne(5000, 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)
{
@ -66,39 +64,42 @@ namespace UpTool2
Online = Ping(metaXml);
#if !DEBUG
if (Application.ExecutablePath != PathTool.GetRelative("Install", "UpTool2.exe"))
{
if (!Online)
throw new WebException("Could fetch Metadata (are you online?)");
if (MessageBox.Show(@"Thank you for downloading UpTool2.
if (Application.ExecutablePath != PathTool.GetRelative("Install", "UpTool2.exe"))
{
if (!Online)
throw new WebException("Could fetch Metadata (are you online?)");
if (MessageBox.Show(@"Thank you for downloading UpTool2.
To prevent inconsistent behavior you will need to install this before running.
Files will be placed in %appdata%\UpTool2 and %appdata%\Microsoft\Windows\Start Menu\Programs
Do you want to continue?", "UpTool2", MessageBoxButtons.YesNo) != DialogResult.Yes)
throw new Exception("Exiting...");
MessageBox.Show("Installing an Update. Please restart from your start menu!");
InstallUpdate(XDocument.Load(metaXml).Element("meta"));
Shortcut.Make(PathTool.GetRelative("Install", "UpTool2.exe"), Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Programs), "UpTool2.lnk"));
mutex.ReleaseMutex();
Environment.Exit(0);
}
if (!File.Exists(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"));
throw new Exception("Exiting...");
MessageBox.Show("Installing an Update. Please restart from your start menu!");
InstallUpdate(XDocument.Load(metaXml).Element("meta"));
Shortcut.Make(PathTool.GetRelative("Install", "UpTool2.exe"),
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Programs), "UpTool2.lnk"));
mutex.ReleaseMutex();
Environment.Exit(0);
}
if (!File.Exists(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"));
#endif
if (!Directory.Exists(PathTool.GetRelative("Apps")))
Directory.CreateDirectory(PathTool.GetRelative("Apps"));
if (!Online || UpdateCheck(metaXml))
Application.Run(new MainForm());
#if !DEBUG
}
catch (Exception e1)
{
MessageBox.Show(e1.ToString());
}
finally
{
if (hasHandle)
mutex.ReleaseMutex();
}
}
catch (Exception e1)
{
MessageBox.Show(e1.ToString());
}
finally
{
if (hasHandle)
mutex.ReleaseMutex();
}
#endif
}
@ -210,8 +211,8 @@ Do you want to continue?", "UpTool2", MessageBoxButtons.YesNo) != DialogResult.Y
Directory.Delete(PathTool.GetRelative("Install", "tmp"), true);
Directory.CreateDirectory(PathTool.GetRelative("Install", "tmp"));
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 =>
{
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);
request.Timeout = 3000;
request.AllowAutoRedirect = false;
request.Method = "HEAD";
request.AllowAutoRedirect = true;
using WebResponse response = request.GetResponse();
return true;
}

View File

@ -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) =>
CompleteInstall(app.appPath, app.Name, app.Description, app.Version, app.MainFile);

View File

@ -37,7 +37,8 @@ namespace UpTool2.Tool
XElement[] tmp_apparray = repo.Element("repo").Elements("app").Where(app =>
!tmpAppsList.Any(a => a.Element("ID").Value == app.Element("ID").Value) ||
!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")
.Select(s => XDocument.Load(s.Value).Element("app"))).ToArray();
for (int i1 = 0; i1 < tmp_apparray.Length; i1++)
@ -99,7 +100,8 @@ namespace UpTool2.Tool
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)
meta.Add(new XElement("LocalRepo"));
XElement repos = meta.Element("LocalRepo");
@ -146,7 +148,8 @@ namespace UpTool2.Tool
#endif
});
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));
try

View File

@ -1,115 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<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')" />
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{C0C1E002-9E13-4E8F-A035-DBDC5128E00E}</ProjectGuid>
<TargetFramework>netcoreapp3.1</TargetFramework>
<OutputType>WinExe</OutputType>
<RootNamespace>UpTool2</RootNamespace>
<AssemblyName>UpTool2</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<LangVersion>latest</LangVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>false</Deterministic>
<TargetFrameworkProfile />
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<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>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject>UpTool2.Program</StartupObject>
</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>
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\C_64.ico" />
<PackageReference Include="CC-Functions.Misc" Version="1.0.7.1" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

27
UpTool2/WindowHelper.cs Normal file
View 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);
}
}