2014-01-13 04:00:28 +13:00
|
|
|
|
#region License Information (GPL v3)
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
ShareX - A program that allows you to take screenshots and share any file type
|
2015-08-13 13:07:38 +12:00
|
|
|
|
Copyright (c) 2007-2015 ShareX Team
|
2014-01-13 04:00:28 +13:00
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
|
|
|
|
|
Optionally you can also view the license at <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#endregion License Information (GPL v3)
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
2014-12-11 09:25:20 +13:00
|
|
|
|
namespace ShareX.Setup
|
2014-01-13 04:00:28 +13:00
|
|
|
|
{
|
|
|
|
|
internal class Program
|
|
|
|
|
{
|
2014-11-14 11:54:00 +13:00
|
|
|
|
private enum SetupType
|
|
|
|
|
{
|
2015-09-06 21:32:34 +12:00
|
|
|
|
Stable, // Build setup & create portable zip file
|
|
|
|
|
Beta, // Build setup & upload it using "Debug/ShareX.exe"
|
|
|
|
|
Steam // Create Steam folder
|
2014-11-14 11:54:00 +13:00
|
|
|
|
}
|
|
|
|
|
|
2015-09-28 01:46:29 +13:00
|
|
|
|
private static readonly SetupType Setup = SetupType.Steam;
|
|
|
|
|
|
|
|
|
|
private static readonly string parentDir = @"..\..\..\";
|
|
|
|
|
private static readonly string binDir = Path.Combine(parentDir, "ShareX", "bin");
|
|
|
|
|
private static readonly string releaseDir = Path.Combine(binDir, "Release");
|
|
|
|
|
private static readonly string debugDir = Path.Combine(binDir, "Debug");
|
|
|
|
|
private static readonly string steamDir = Path.Combine(binDir, "Steam");
|
|
|
|
|
private static readonly string debugPath = Path.Combine(debugDir, "ShareX.exe");
|
|
|
|
|
private static readonly string outputDir = Path.Combine(parentDir, "InnoSetup", "Output");
|
|
|
|
|
private static readonly string portableDir = Path.Combine(outputDir, "ShareX-portable");
|
|
|
|
|
private static readonly string steamOutputDir = Path.Combine(outputDir, "ShareX");
|
|
|
|
|
private static readonly string steamLauncherDir = Path.Combine(parentDir, @"..\ShareX_Steam\ShareX_Steam\bin\Release");
|
|
|
|
|
private static readonly string steamUpdatesDir = Path.Combine(steamOutputDir, "Updates");
|
2015-09-28 20:32:58 +13:00
|
|
|
|
private static readonly string chromeReleaseDir = Path.Combine(parentDir, @"..\ShareX_Chrome\ShareX_Chrome\bin\Release");
|
2015-09-28 01:46:29 +13:00
|
|
|
|
private static readonly string innoSetupPath = @"C:\Program Files (x86)\Inno Setup 5\ISCC.exe";
|
|
|
|
|
private static readonly string innoSetupScriptPath = Path.Combine(parentDir, "InnoSetup", "ShareX setup.iss");
|
2015-09-06 21:32:34 +12:00
|
|
|
|
|
|
|
|
|
private static string ReleaseDirectory => Setup == SetupType.Steam ? steamDir : releaseDir;
|
2014-11-14 11:54:00 +13:00
|
|
|
|
|
2014-01-13 04:00:28 +13:00
|
|
|
|
private static void Main(string[] args)
|
|
|
|
|
{
|
2015-09-06 21:32:34 +12:00
|
|
|
|
Console.WriteLine("Setup type: " + Setup);
|
|
|
|
|
|
2014-11-14 11:54:00 +13:00
|
|
|
|
switch (Setup)
|
|
|
|
|
{
|
|
|
|
|
case SetupType.Stable:
|
2014-11-22 02:34:50 +13:00
|
|
|
|
CompileSetup();
|
2015-09-06 21:32:34 +12:00
|
|
|
|
CreatePortable(portableDir);
|
2014-11-14 11:54:00 +13:00
|
|
|
|
OpenOutputDirectory();
|
|
|
|
|
break;
|
|
|
|
|
case SetupType.Beta:
|
2014-11-22 02:34:50 +13:00
|
|
|
|
CompileSetup();
|
2014-11-14 11:54:00 +13:00
|
|
|
|
UploadLatestFile();
|
|
|
|
|
break;
|
2015-09-06 19:17:32 +12:00
|
|
|
|
case SetupType.Steam:
|
2015-09-06 21:32:34 +12:00
|
|
|
|
CreateSteamFolder();
|
2015-09-06 19:17:32 +12:00
|
|
|
|
OpenOutputDirectory();
|
|
|
|
|
break;
|
2014-11-14 11:54:00 +13:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Console.WriteLine("Done.");
|
|
|
|
|
//Console.Read();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void OpenOutputDirectory()
|
|
|
|
|
{
|
|
|
|
|
Process.Start("explorer.exe", outputDir);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void UploadLatestFile()
|
|
|
|
|
{
|
|
|
|
|
FileInfo fileInfo = new DirectoryInfo(outputDir).GetFiles("*.exe").OrderByDescending(f => f.LastWriteTime).FirstOrDefault();
|
|
|
|
|
if (fileInfo != null)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("Uploading setup file...");
|
|
|
|
|
Process.Start(debugPath, fileInfo.FullName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-22 02:34:50 +13:00
|
|
|
|
private static void CompileSetup()
|
2014-11-14 11:54:00 +13:00
|
|
|
|
{
|
2014-11-22 02:34:50 +13:00
|
|
|
|
Console.WriteLine("Compiling setup...");
|
|
|
|
|
Process.Start(innoSetupPath, string.Format("\"{0}\"", innoSetupScriptPath)).WaitForExit();
|
2014-11-14 11:54:00 +13:00
|
|
|
|
Console.WriteLine("Setup file created.");
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-06 21:32:34 +12:00
|
|
|
|
private static void CreateSteamFolder()
|
|
|
|
|
{
|
|
|
|
|
if (Directory.Exists(steamOutputDir))
|
|
|
|
|
{
|
|
|
|
|
Directory.Delete(steamOutputDir, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Directory.CreateDirectory(steamOutputDir);
|
|
|
|
|
|
2015-09-06 22:10:16 +12:00
|
|
|
|
CopyFile(Path.Combine(steamLauncherDir, "ShareX_Launcher.exe"), steamOutputDir);
|
2015-09-13 18:31:16 +12:00
|
|
|
|
CopyFile(Path.Combine(steamLauncherDir, "steam_appid.txt"), steamOutputDir);
|
2015-09-12 11:38:10 +12:00
|
|
|
|
CopyFile(Path.Combine(steamLauncherDir, "installscript.vdf"), steamOutputDir);
|
2015-09-06 22:10:16 +12:00
|
|
|
|
CopyFiles(steamLauncherDir, "*.dll", steamOutputDir);
|
2015-09-06 21:32:34 +12:00
|
|
|
|
|
|
|
|
|
CreatePortable(steamUpdatesDir);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void CreatePortable(string destination)
|
2014-11-14 11:54:00 +13:00
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("Creating portable...");
|
2014-01-13 04:00:28 +13:00
|
|
|
|
|
2015-09-06 21:32:34 +12:00
|
|
|
|
if (Directory.Exists(destination))
|
2014-11-14 12:28:07 +13:00
|
|
|
|
{
|
2015-09-06 21:32:34 +12:00
|
|
|
|
Directory.Delete(destination, true);
|
2014-11-14 12:28:07 +13:00
|
|
|
|
}
|
|
|
|
|
|
2015-09-06 21:32:34 +12:00
|
|
|
|
Directory.CreateDirectory(destination);
|
2014-11-14 12:28:07 +13:00
|
|
|
|
|
2015-09-28 01:46:29 +13:00
|
|
|
|
CopyFile(Path.Combine(ReleaseDirectory, "ShareX.exe"), destination);
|
|
|
|
|
CopyFile(Path.Combine(ReleaseDirectory, "ShareX.exe.config"), destination);
|
|
|
|
|
CopyFiles(ReleaseDirectory, "*.dll", destination);
|
|
|
|
|
CopyFiles(Path.Combine(parentDir, "Licenses"), "*.txt", Path.Combine(destination, "Licenses"));
|
|
|
|
|
CopyFile(Path.Combine(outputDir, "Recorder-devices-setup.exe"), destination);
|
2015-09-28 20:32:58 +13:00
|
|
|
|
CopyFile(Path.Combine(chromeReleaseDir, "ShareX_Chrome.exe"), destination);
|
2014-01-13 04:00:28 +13:00
|
|
|
|
|
2015-08-25 06:32:24 +12:00
|
|
|
|
string[] languages = new string[] { "de", "es", "fr", "hu", "ko-KR", "nl-NL", "pt-BR", "tr", "zh-CN" };
|
2015-01-05 05:53:04 +13:00
|
|
|
|
|
|
|
|
|
foreach (string language in languages)
|
|
|
|
|
{
|
2015-09-06 21:32:34 +12:00
|
|
|
|
CopyFiles(Path.Combine(ReleaseDirectory, language), "*.resources.dll", Path.Combine(destination, "Languages", language));
|
2015-01-05 05:53:04 +13:00
|
|
|
|
}
|
2014-01-13 04:00:28 +13:00
|
|
|
|
|
2015-09-13 08:32:51 +12:00
|
|
|
|
if (Setup == SetupType.Steam)
|
|
|
|
|
{
|
|
|
|
|
// These git ignored
|
|
|
|
|
CopyFile(Path.Combine(parentDir, "Lib", "ffmpeg.exe"), destination);
|
|
|
|
|
CopyFile(Path.Combine(parentDir, "Lib", "ffmpeg-x64.exe"), destination);
|
|
|
|
|
}
|
2015-09-28 01:46:29 +13:00
|
|
|
|
else
|
2015-09-06 21:32:34 +12:00
|
|
|
|
{
|
|
|
|
|
File.WriteAllText(Path.Combine(destination, "PersonalPath.cfg"), "ShareX", Encoding.UTF8);
|
2014-01-13 04:00:28 +13:00
|
|
|
|
|
2015-09-06 21:32:34 +12:00
|
|
|
|
//FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(Path.Combine(releaseDir, "ShareX.exe"));
|
|
|
|
|
//string zipFilename = string.Format("ShareX-{0}.{1}.{2}-portable.zip", versionInfo.ProductMajorPart, versionInfo.ProductMinorPart, versionInfo.ProductBuildPart);
|
|
|
|
|
string zipPath = Path.Combine(outputDir, "ShareX-portable.zip");
|
2014-01-13 05:05:31 +13:00
|
|
|
|
|
2015-09-06 21:32:34 +12:00
|
|
|
|
if (File.Exists(zipPath))
|
|
|
|
|
{
|
|
|
|
|
File.Delete(zipPath);
|
|
|
|
|
}
|
2014-01-13 05:05:31 +13:00
|
|
|
|
|
2015-09-06 21:32:34 +12:00
|
|
|
|
Zip(destination + "\\*.*", zipPath);
|
2014-01-13 05:05:31 +13:00
|
|
|
|
|
2015-09-06 21:32:34 +12:00
|
|
|
|
if (Directory.Exists(destination))
|
|
|
|
|
{
|
|
|
|
|
Directory.Delete(destination, true);
|
|
|
|
|
}
|
2014-01-16 08:12:59 +13:00
|
|
|
|
}
|
2014-01-13 04:00:28 +13:00
|
|
|
|
|
2014-11-14 11:54:00 +13:00
|
|
|
|
Console.WriteLine("Portable created.");
|
2014-01-13 04:00:28 +13:00
|
|
|
|
}
|
2014-01-13 05:05:31 +13:00
|
|
|
|
|
2015-09-28 01:46:29 +13:00
|
|
|
|
private static void CopyFiles(string[] files, string toFolder)
|
2014-11-14 12:28:07 +13:00
|
|
|
|
{
|
2015-09-03 01:46:20 +12:00
|
|
|
|
if (!Directory.Exists(toFolder))
|
|
|
|
|
{
|
|
|
|
|
Directory.CreateDirectory(toFolder);
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-14 12:28:07 +13:00
|
|
|
|
foreach (string filepath in files)
|
|
|
|
|
{
|
|
|
|
|
string filename = Path.GetFileName(filepath);
|
|
|
|
|
string dest = Path.Combine(toFolder, filename);
|
|
|
|
|
File.Copy(filepath, dest);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-03 01:46:20 +12:00
|
|
|
|
private static void CopyFile(string path, string toFolder)
|
|
|
|
|
{
|
2015-09-05 18:51:38 +12:00
|
|
|
|
CopyFiles(new string[] { path }, toFolder);
|
2015-09-03 01:46:20 +12:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void CopyFiles(string directory, string searchPattern, string toFolder)
|
2014-11-14 12:28:07 +13:00
|
|
|
|
{
|
2015-09-03 01:46:20 +12:00
|
|
|
|
CopyFiles(Directory.GetFiles(directory, searchPattern), toFolder);
|
2014-11-14 12:28:07 +13:00
|
|
|
|
}
|
|
|
|
|
|
2014-01-13 05:05:31 +13:00
|
|
|
|
private static void Zip(string source, string target)
|
|
|
|
|
{
|
|
|
|
|
ProcessStartInfo p = new ProcessStartInfo();
|
|
|
|
|
p.FileName = "7za.exe";
|
2014-11-14 12:28:07 +13:00
|
|
|
|
p.Arguments = string.Format("a -tzip \"{0}\" \"{1}\" -r -mx=9", target, source);
|
2014-01-13 05:05:31 +13:00
|
|
|
|
p.WindowStyle = ProcessWindowStyle.Hidden;
|
|
|
|
|
Process process = Process.Start(p);
|
|
|
|
|
process.WaitForExit();
|
|
|
|
|
}
|
2014-01-13 04:00:28 +13:00
|
|
|
|
}
|
|
|
|
|
}
|