diff --git a/.gitignore b/.gitignore index b5744d1e3..81b41f6d8 100644 --- a/.gitignore +++ b/.gitignore @@ -108,6 +108,4 @@ Backup*/ UpgradeLog*.XML # Additional -*.exe -*.userprefs -Output/ +Output/ \ No newline at end of file diff --git a/ShareXPortable/7za.exe b/ShareXPortable/7za.exe new file mode 100644 index 000000000..7f6bf86bc Binary files /dev/null and b/ShareXPortable/7za.exe differ diff --git a/ShareXPortable/Program.cs b/ShareXPortable/Program.cs index 66a826dc3..57f5eb4f7 100644 --- a/ShareXPortable/Program.cs +++ b/ShareXPortable/Program.cs @@ -38,7 +38,8 @@ private static void Main(string[] args) { string parentDir = @"..\..\..\"; string releaseDir = Path.Combine(parentDir, @"ShareX\bin\Release"); - string portableDir = Path.Combine(parentDir, @"Output\Portable"); + string outputDir = Path.Combine(parentDir, "Output"); + string portableDir = Path.Combine(outputDir, "Portable"); List files = new List(); @@ -75,10 +76,33 @@ private static void Main(string[] args) File.WriteAllText(Path.Combine(portableDir, "PersonalPath.cfg"), "ShareX", Encoding.UTF8); Console.WriteLine("Created PersonalPath.cfg file."); - Process.Start("explorer.exe", portableDir); + FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(Path.Combine(releaseDir, "ShareX.exe")); + string version = string.Format("{0}.{1}", versionInfo.ProductMajorPart, versionInfo.ProductMinorPart); + if (versionInfo.ProductBuildPart > 0) version += "." + versionInfo.ProductBuildPart; + string zipFilename = string.Format("ShareX-{0}-Portable.zip", version); + string zipPath = Path.Combine(outputDir, zipFilename); + + if (File.Exists(zipPath)) + { + File.Delete(zipPath); + } + + Zip(portableDir + "\\*.*", zipPath); + + Process.Start("explorer.exe", outputDir); Console.WriteLine("Done."); //Console.Read(); } + + private static void Zip(string source, string target) + { + ProcessStartInfo p = new ProcessStartInfo(); + p.FileName = "7za.exe"; + p.Arguments = string.Format("a -tzip \"{0}\" \"{1}\" -mx=9", target, source); + p.WindowStyle = ProcessWindowStyle.Hidden; + Process process = Process.Start(p); + process.WaitForExit(); + } } } \ No newline at end of file diff --git a/ShareXPortable/ShareXPortable.csproj b/ShareXPortable/ShareXPortable.csproj index b2c59bc3b..c4eff04c2 100644 --- a/ShareXPortable/ShareXPortable.csproj +++ b/ShareXPortable/ShareXPortable.csproj @@ -39,6 +39,11 @@ + + + PreserveNewest + +