mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 01:37:31 +13:00
Creating portable zip automatically
This commit is contained in:
parent
e97a24e19a
commit
6f3ae5ad6f
4 changed files with 32 additions and 5 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -108,6 +108,4 @@ Backup*/
|
||||||
UpgradeLog*.XML
|
UpgradeLog*.XML
|
||||||
|
|
||||||
# Additional
|
# Additional
|
||||||
*.exe
|
|
||||||
*.userprefs
|
|
||||||
Output/
|
Output/
|
BIN
ShareXPortable/7za.exe
Normal file
BIN
ShareXPortable/7za.exe
Normal file
Binary file not shown.
|
@ -38,7 +38,8 @@ private static void Main(string[] args)
|
||||||
{
|
{
|
||||||
string parentDir = @"..\..\..\";
|
string parentDir = @"..\..\..\";
|
||||||
string releaseDir = Path.Combine(parentDir, @"ShareX\bin\Release");
|
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<string> files = new List<string>();
|
List<string> files = new List<string>();
|
||||||
|
|
||||||
|
@ -75,10 +76,33 @@ private static void Main(string[] args)
|
||||||
File.WriteAllText(Path.Combine(portableDir, "PersonalPath.cfg"), "ShareX", Encoding.UTF8);
|
File.WriteAllText(Path.Combine(portableDir, "PersonalPath.cfg"), "ShareX", Encoding.UTF8);
|
||||||
Console.WriteLine("Created PersonalPath.cfg file.");
|
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.WriteLine("Done.");
|
||||||
//Console.Read();
|
//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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -39,6 +39,11 @@
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="7za.exe">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
|
Loading…
Reference in a new issue