From 0b9d7e43a6c55dc542e2af88335db4222a9da754 Mon Sep 17 00:00:00 2001 From: Jaex Date: Fri, 26 Aug 2016 03:01:05 +0300 Subject: [PATCH] Adding AppVeyor setup type --- ShareX.Setup/Program.cs | 68 +++++++++++++++++++++++++++++++++++++---- ShareX.sln | 3 ++ 2 files changed, 65 insertions(+), 6 deletions(-) diff --git a/ShareX.Setup/Program.cs b/ShareX.Setup/Program.cs index 6fc246543..7690942ad 100644 --- a/ShareX.Setup/Program.cs +++ b/ShareX.Setup/Program.cs @@ -27,6 +27,7 @@ You should have received a copy of the GNU General Public License using System.Diagnostics; using System.IO; using System.Linq; +using System.Net; namespace ShareX.Setup { @@ -39,10 +40,11 @@ private enum SetupType CreatePortable, // Create portable zip file PortableApps, // Create PortableApps folder Beta, // Build setup & upload it using "Debug/ShareX.exe" - Steam // Create Steam folder + Steam, // Create Steam folder + AppVeyor } - private static readonly SetupType Setup = SetupType.Stable; + private static SetupType Setup = SetupType.Stable; private static readonly string parentDir = @"..\..\..\"; private static readonly string binDir = Path.Combine(parentDir, "ShareX", "bin"); @@ -66,6 +68,13 @@ private enum SetupType private static void Main(string[] args) { + Console.WriteLine("ShareX.Setup started."); + + if (CheckArgs(args, "-appveyor")) + { + Setup = SetupType.AppVeyor; + } + Console.WriteLine("Setup type: " + Setup); switch (Setup) @@ -95,9 +104,28 @@ private static void Main(string[] args) CreateSteamFolder(); OpenOutputDirectory(); break; + case SetupType.AppVeyor: + CompileSetup(); + break; } - Console.WriteLine("Done."); + Console.WriteLine("ShareX.Setup successfully completed."); + } + + private static bool CheckArgs(string[] args, string check) + { + if (!string.IsNullOrEmpty(check)) + { + foreach (string arg in args) + { + if (!string.IsNullOrEmpty(arg) && arg.Equals(check, StringComparison.InvariantCultureIgnoreCase)) + { + return true; + } + } + } + + return false; } private static void OpenOutputDirectory() @@ -117,9 +145,37 @@ private static void UploadLatestFile() private static void CompileSetup() { - Console.WriteLine("Compiling setup..."); - Process.Start(innoSetupCompilerPath, string.Format("\"{0}\"", innoSetupScriptPath)).WaitForExit(); - Console.WriteLine("Setup file created."); + if (Setup == SetupType.AppVeyor && !File.Exists(innoSetupCompilerPath)) + { + Console.WriteLine("Downloading InnoSetup."); + + string innoSetupURL = "http://files.jrsoftware.org/is/5/innosetup-5.5.9-unicode.exe"; + string innoSetupFilename = "innosetup-5.5.9-unicode.exe"; + + using (WebClient webClient = new WebClient()) + { + webClient.DownloadFile(innoSetupURL, innoSetupFilename); + } + + Console.WriteLine("Installing InnoSetup..."); + + Process.Start(innoSetupFilename, "/VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-").WaitForExit(); + + Console.WriteLine("InnoSetup installed."); + } + + if (File.Exists(innoSetupCompilerPath)) + { + Console.WriteLine("Compiling setup file."); + + Process.Start(innoSetupCompilerPath, $"\"{innoSetupScriptPath}\"").WaitForExit(); + + Console.WriteLine("Setup file is created: " + innoSetupScriptPath); + } + else + { + Console.WriteLine("InnoSetup compiler is missing: " + innoSetupCompilerPath); + } } private static void CreateSteamFolder() diff --git a/ShareX.sln b/ShareX.sln index 4c5b76d18..f3df12671 100644 --- a/ShareX.sln +++ b/ShareX.sln @@ -86,8 +86,11 @@ Global {D13441B6-96E1-4D1B-8A95-58A7D6CB1E24}.Steam|Any CPU.ActiveCfg = Steam|Any CPU {D13441B6-96E1-4D1B-8A95-58A7D6CB1E24}.Steam|Any CPU.Build.0 = Steam|Any CPU {3D19A94A-7A58-4451-A686-EE70B471C206}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3D19A94A-7A58-4451-A686-EE70B471C206}.Debug|Any CPU.Build.0 = Debug|Any CPU {3D19A94A-7A58-4451-A686-EE70B471C206}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3D19A94A-7A58-4451-A686-EE70B471C206}.Release|Any CPU.Build.0 = Release|Any CPU {3D19A94A-7A58-4451-A686-EE70B471C206}.Steam|Any CPU.ActiveCfg = Steam|Any CPU + {3D19A94A-7A58-4451-A686-EE70B471C206}.Steam|Any CPU.Build.0 = Steam|Any CPU {1A190E53-1419-4CC2-B0E5-3BC7EA861C8B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1A190E53-1419-4CC2-B0E5-3BC7EA861C8B}.Debug|Any CPU.Build.0 = Debug|Any CPU {1A190E53-1419-4CC2-B0E5-3BC7EA861C8B}.Release|Any CPU.ActiveCfg = Release|Any CPU