mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 09:47:22 +13:00
Code refactoring
This commit is contained in:
parent
b178657d3f
commit
5ef51bf285
1 changed files with 51 additions and 32 deletions
|
@ -98,11 +98,12 @@ private static string Configuration
|
||||||
private static string InnoSetupDir => Path.Combine(SetupDir, "InnoSetup");
|
private static string InnoSetupDir => Path.Combine(SetupDir, "InnoSetup");
|
||||||
private static string MicrosoftStorePackageFilesDir => Path.Combine(SetupDir, "MicrosoftStore");
|
private static string MicrosoftStorePackageFilesDir => Path.Combine(SetupDir, "MicrosoftStore");
|
||||||
|
|
||||||
|
private static string SetupPath => Path.Combine(OutputDir, $"ShareX-{AppVersion}-setup.exe");
|
||||||
|
private static string RecorderDevicesSetupPath => Path.Combine(OutputDir, "Recorder-devices-setup.exe");
|
||||||
private static string PortableZipPath => Path.Combine(OutputDir, $"ShareX-{AppVersion}-portable.zip");
|
private static string PortableZipPath => Path.Combine(OutputDir, $"ShareX-{AppVersion}-portable.zip");
|
||||||
private static string DebugZipPath => Path.Combine(OutputDir, $"ShareX-{AppVersion}-debug.zip");
|
private static string DebugZipPath => Path.Combine(OutputDir, $"ShareX-{AppVersion}-debug.zip");
|
||||||
private static string SteamUpdatesDir => Path.Combine(SteamOutputDir, "Updates");
|
private static string SteamUpdatesDir => Path.Combine(SteamOutputDir, "Updates");
|
||||||
private static string SteamZipPath => Path.Combine(OutputDir, $"ShareX-{AppVersion}-Steam.zip");
|
private static string SteamZipPath => Path.Combine(OutputDir, $"ShareX-{AppVersion}-Steam.zip");
|
||||||
private static string RecorderDevicesSetupPath => Path.Combine(OutputDir, "Recorder-devices-setup.exe");
|
|
||||||
private static string MicrosoftStoreAppxPath => Path.Combine(OutputDir, $"ShareX-{AppVersion}.appx");
|
private static string MicrosoftStoreAppxPath => Path.Combine(OutputDir, $"ShareX-{AppVersion}.appx");
|
||||||
private static string FFmpegPath => Path.Combine(OutputDir, "ffmpeg.exe");
|
private static string FFmpegPath => Path.Combine(OutputDir, "ffmpeg.exe");
|
||||||
|
|
||||||
|
@ -164,32 +165,7 @@ private static void Main(string[] args)
|
||||||
|
|
||||||
if (Job.HasFlag(SetupJobs.CompileAppx))
|
if (Job.HasFlag(SetupJobs.CompileAppx))
|
||||||
{
|
{
|
||||||
using (Process process = new Process())
|
CompileAppx();
|
||||||
{
|
|
||||||
ProcessStartInfo psi = new ProcessStartInfo()
|
|
||||||
{
|
|
||||||
FileName = MakeAppxPath,
|
|
||||||
Arguments = $"pack /d \"{MicrosoftStoreOutputDir}\" /p \"{MicrosoftStoreAppxPath}\" /l /o",
|
|
||||||
UseShellExecute = false,
|
|
||||||
RedirectStandardOutput = true
|
|
||||||
};
|
|
||||||
|
|
||||||
process.OutputDataReceived += (s, e) => Console.WriteLine(e.Data);
|
|
||||||
process.StartInfo = psi;
|
|
||||||
process.Start();
|
|
||||||
process.BeginOutputReadLine();
|
|
||||||
process.WaitForExit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Job.HasFlag(SetupJobs.CreateChecksumFile))
|
|
||||||
{
|
|
||||||
Console.WriteLine("Creating checksum files.");
|
|
||||||
|
|
||||||
foreach (string file in Directory.GetFiles(OutputDir))
|
|
||||||
{
|
|
||||||
Helpers.CreateChecksumFile(file);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AppVeyor)
|
if (AppVeyor)
|
||||||
|
@ -253,6 +229,7 @@ private static void CompileSetup()
|
||||||
{
|
{
|
||||||
CompileISSFile("Recorder-devices-setup.iss");
|
CompileISSFile("Recorder-devices-setup.iss");
|
||||||
CompileISSFile("ShareX-setup.iss");
|
CompileISSFile("ShareX-setup.iss");
|
||||||
|
CreateChecksumFile(SetupPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void CompileISSFile(string fileName)
|
private static void CompileISSFile(string fileName)
|
||||||
|
@ -276,7 +253,7 @@ private static void CompileISSFile(string fileName)
|
||||||
process.WaitForExit();
|
process.WaitForExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.WriteLine("Setup file is created.");
|
Console.WriteLine("Setup file compiled.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -284,6 +261,30 @@ private static void CompileISSFile(string fileName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void CompileAppx()
|
||||||
|
{
|
||||||
|
Console.WriteLine("Compiling appx file: " + MicrosoftStoreAppxPath);
|
||||||
|
|
||||||
|
using (Process process = new Process())
|
||||||
|
{
|
||||||
|
ProcessStartInfo psi = new ProcessStartInfo()
|
||||||
|
{
|
||||||
|
FileName = MakeAppxPath,
|
||||||
|
Arguments = $"pack /d \"{MicrosoftStoreOutputDir}\" /p \"{MicrosoftStoreAppxPath}\" /l /o",
|
||||||
|
UseShellExecute = false,
|
||||||
|
RedirectStandardOutput = true
|
||||||
|
};
|
||||||
|
|
||||||
|
process.OutputDataReceived += (s, e) => Console.WriteLine(e.Data);
|
||||||
|
process.StartInfo = psi;
|
||||||
|
process.Start();
|
||||||
|
process.BeginOutputReadLine();
|
||||||
|
process.WaitForExit();
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine("Appx file compiled.");
|
||||||
|
}
|
||||||
|
|
||||||
private static void CreateSteamFolder()
|
private static void CreateSteamFolder()
|
||||||
{
|
{
|
||||||
Console.WriteLine("Creating Steam folder: " + SteamOutputDir);
|
Console.WriteLine("Creating Steam folder: " + SteamOutputDir);
|
||||||
|
@ -355,15 +356,15 @@ private static void CreateFolder(string source, string destination, SetupJobs jo
|
||||||
if (job == SetupJobs.CreatePortable)
|
if (job == SetupJobs.CreatePortable)
|
||||||
{
|
{
|
||||||
FileHelpers.CreateEmptyFile(Path.Combine(destination, "Portable"));
|
FileHelpers.CreateEmptyFile(Path.Combine(destination, "Portable"));
|
||||||
ZipManager.Compress(Path.GetFullPath(destination), Path.GetFullPath(PortableZipPath));
|
CreateZipFile(destination, PortableZipPath);
|
||||||
}
|
}
|
||||||
else if (job == SetupJobs.CreateDebug)
|
else if (job == SetupJobs.CreateDebug)
|
||||||
{
|
{
|
||||||
ZipManager.Compress(Path.GetFullPath(destination), Path.GetFullPath(DebugZipPath));
|
CreateZipFile(destination, DebugZipPath);
|
||||||
}
|
}
|
||||||
else if (job == SetupJobs.CreateSteamFolder)
|
else if (job == SetupJobs.CreateSteamFolder)
|
||||||
{
|
{
|
||||||
ZipManager.Compress(Path.GetFullPath(destination), Path.GetFullPath(SteamZipPath));
|
CreateZipFile(destination, SteamZipPath);
|
||||||
}
|
}
|
||||||
else if (job == SetupJobs.CreateMicrosoftStoreFolder || job == SetupJobs.CreateMicrosoftStoreDebugFolder)
|
else if (job == SetupJobs.CreateMicrosoftStoreFolder || job == SetupJobs.CreateMicrosoftStoreDebugFolder)
|
||||||
{
|
{
|
||||||
|
@ -373,6 +374,14 @@ private static void CreateFolder(string source, string destination, SetupJobs jo
|
||||||
Console.WriteLine("Folder created.");
|
Console.WriteLine("Folder created.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void CreateZipFile(string source, string archivePath)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Creating zip file: " + archivePath);
|
||||||
|
|
||||||
|
ZipManager.Compress(Path.GetFullPath(source), Path.GetFullPath(archivePath));
|
||||||
|
CreateChecksumFile(archivePath);
|
||||||
|
}
|
||||||
|
|
||||||
private static void DownloadFFmpeg()
|
private static void DownloadFFmpeg()
|
||||||
{
|
{
|
||||||
if (!File.Exists(FFmpegPath))
|
if (!File.Exists(FFmpegPath))
|
||||||
|
@ -381,5 +390,15 @@ private static void DownloadFFmpeg()
|
||||||
ZipManager.Extract(filePath, OutputDir, false, entry => entry.Name.Equals("ffmpeg.exe", StringComparison.OrdinalIgnoreCase), 200_000_000);
|
ZipManager.Extract(filePath, OutputDir, false, entry => entry.Name.Equals("ffmpeg.exe", StringComparison.OrdinalIgnoreCase), 200_000_000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void CreateChecksumFile(string filePath)
|
||||||
|
{
|
||||||
|
if (Job.HasFlag(SetupJobs.CreateChecksumFile))
|
||||||
|
{
|
||||||
|
Console.WriteLine("Creating checksum file: " + filePath);
|
||||||
|
|
||||||
|
Helpers.CreateChecksumFile(filePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue