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
|
2014-05-13 21:06:40 +12:00
|
|
|
|
Copyright (C) 2007-2014 ShareX Developers
|
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;
|
2014-11-14 12:28:07 +13:00
|
|
|
|
using System.Collections;
|
2014-01-13 04:00:28 +13:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
2014-11-14 12:28:07 +13:00
|
|
|
|
namespace ShareX
|
2014-01-13 04:00:28 +13:00
|
|
|
|
{
|
|
|
|
|
internal class Program
|
|
|
|
|
{
|
2014-11-14 11:54:00 +13:00
|
|
|
|
private enum SetupType
|
|
|
|
|
{
|
2014-11-22 02:34:50 +13:00
|
|
|
|
Stable, // Build setup + create portable zip file
|
|
|
|
|
Beta // Build setup + upload it using "Debug/ShareX.exe"
|
2014-11-14 11:54:00 +13:00
|
|
|
|
}
|
|
|
|
|
|
2014-11-28 15:22:28 +13:00
|
|
|
|
private const SetupType Setup = SetupType.Stable;
|
2014-11-14 11:54:00 +13:00
|
|
|
|
|
|
|
|
|
private static string parentDir = @"..\..\..\";
|
|
|
|
|
private static string binDir = Path.Combine(parentDir, @"ShareX\bin");
|
|
|
|
|
private static string releaseDir = Path.Combine(binDir, "Release");
|
|
|
|
|
private static string debugDir = Path.Combine(binDir, "Debug");
|
|
|
|
|
private static string releasePath = Path.Combine(releaseDir, "ShareX.exe");
|
|
|
|
|
private static string debugPath = Path.Combine(debugDir, "ShareX.exe");
|
|
|
|
|
private static string outputDir = Path.Combine(parentDir, @"InnoSetup\Output");
|
|
|
|
|
private static string portableDir = Path.Combine(outputDir, "ShareX-portable");
|
|
|
|
|
private static string innoSetupPath = @"C:\Program Files (x86)\Inno Setup 5\ISCC.exe";
|
|
|
|
|
private static string innoSetupScriptPath = Path.Combine(parentDir, @"InnoSetup\ShareX setup.iss");
|
|
|
|
|
|
2014-01-13 04:00:28 +13:00
|
|
|
|
private static void Main(string[] args)
|
|
|
|
|
{
|
2014-11-14 11:54:00 +13:00
|
|
|
|
switch (Setup)
|
|
|
|
|
{
|
|
|
|
|
case SetupType.Stable:
|
2014-11-22 02:34:50 +13:00
|
|
|
|
CompileSetup();
|
2014-11-14 11:54:00 +13:00
|
|
|
|
CreatePortable();
|
|
|
|
|
OpenOutputDirectory();
|
|
|
|
|
break;
|
|
|
|
|
case SetupType.Beta:
|
2014-11-22 02:34:50 +13:00
|
|
|
|
CompileSetup();
|
2014-11-14 11:54:00 +13:00
|
|
|
|
UploadLatestFile();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void CreatePortable()
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("Creating portable...");
|
2014-01-13 04:00:28 +13:00
|
|
|
|
|
2014-11-14 12:28:07 +13:00
|
|
|
|
if (Directory.Exists(portableDir))
|
|
|
|
|
{
|
|
|
|
|
Directory.Delete(portableDir, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Directory.CreateDirectory(portableDir);
|
|
|
|
|
|
2014-01-13 04:00:28 +13:00
|
|
|
|
List<string> files = new List<string>();
|
|
|
|
|
|
2014-11-14 12:28:07 +13:00
|
|
|
|
string[] endsWith = new string[] { "ShareX.exe", "ShareX.exe.config", ".dll", ".css", ".txt" };
|
|
|
|
|
string[] ignoreEndsWith = new string[] { };
|
2014-01-13 04:00:28 +13:00
|
|
|
|
|
|
|
|
|
foreach (string filepath in Directory.GetFiles(releaseDir))
|
|
|
|
|
{
|
|
|
|
|
if (endsWith.Any(x => filepath.EndsWith(x, StringComparison.InvariantCultureIgnoreCase)) &&
|
|
|
|
|
ignoreEndsWith.All(x => !filepath.EndsWith(x, StringComparison.InvariantCultureIgnoreCase)))
|
|
|
|
|
{
|
|
|
|
|
files.Add(filepath);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-14 12:28:07 +13:00
|
|
|
|
CopyFiles(files, portableDir);
|
2014-01-13 04:00:28 +13:00
|
|
|
|
|
2014-11-14 12:28:07 +13:00
|
|
|
|
CopyFiles(Path.Combine(releaseDir, @"tr\*.resources.dll"), Path.Combine(portableDir, @"Languages\tr"));
|
2014-01-13 04:00:28 +13:00
|
|
|
|
|
|
|
|
|
File.WriteAllText(Path.Combine(portableDir, "PersonalPath.cfg"), "ShareX", Encoding.UTF8);
|
|
|
|
|
|
2014-01-16 08:12:59 +13: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
|
|
|
|
|
|
|
|
|
if (File.Exists(zipPath))
|
|
|
|
|
{
|
|
|
|
|
File.Delete(zipPath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Zip(portableDir + "\\*.*", zipPath);
|
|
|
|
|
|
2014-01-16 08:12:59 +13:00
|
|
|
|
if (Directory.Exists(portableDir))
|
|
|
|
|
{
|
|
|
|
|
Directory.Delete(portableDir, true);
|
|
|
|
|
}
|
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
|
|
|
|
|
2014-11-14 12:28:07 +13:00
|
|
|
|
private static void CopyFiles(IEnumerable files, string toFolder)
|
|
|
|
|
{
|
|
|
|
|
foreach (string filepath in files)
|
|
|
|
|
{
|
|
|
|
|
string filename = Path.GetFileName(filepath);
|
|
|
|
|
string dest = Path.Combine(toFolder, filename);
|
|
|
|
|
|
|
|
|
|
File.Copy(filepath, dest);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void CopyFiles(string path, string toFolder)
|
|
|
|
|
{
|
|
|
|
|
string directory = Path.GetDirectoryName(path);
|
|
|
|
|
string filename = Path.GetFileName(path);
|
|
|
|
|
if (!Directory.Exists(toFolder)) Directory.CreateDirectory(toFolder);
|
|
|
|
|
CopyFiles(Directory.GetFiles(directory, filename), toFolder);
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
}
|