85 lines
3.4 KiB
C#
85 lines
3.4 KiB
C#
using System.Diagnostics;
|
|
using System.IO.Compression;
|
|
|
|
public class Program
|
|
{
|
|
public static string? FindNSIS()
|
|
{
|
|
string pf=Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
|
|
string pf86 = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86);
|
|
|
|
if(Directory.Exists(Path.Combine(pf,"NSIS")))
|
|
{
|
|
return Path.Combine(pf,"NSIS","makensis.exe");
|
|
|
|
}
|
|
if(Directory.Exists(Path.Combine(pf86,"NSIS")))
|
|
{
|
|
return Path.Combine(pf86,"NSIS","makensis.exe");
|
|
}
|
|
return null;
|
|
}
|
|
public static void RunProcess(string filename,string args,string dir)
|
|
{
|
|
using(Process p=new Process()){
|
|
|
|
p.StartInfo.FileName=filename;
|
|
p.StartInfo.Arguments=args;
|
|
p.StartInfo.UseShellExecute=false;
|
|
p.StartInfo.WorkingDirectory=dir;
|
|
if(p.Start())
|
|
{
|
|
p.WaitForExit();
|
|
}
|
|
}
|
|
}
|
|
public static void Main(string[] args)
|
|
{
|
|
string? nsis=FindNSIS();
|
|
if(string.IsNullOrWhiteSpace(nsis))
|
|
{
|
|
Console.WriteLine("Only run this builder on windows");
|
|
Console.WriteLine("NSIS also not found on your system: https://nsis.sourceforge.io/Download");
|
|
|
|
}
|
|
|
|
string p=Path.Combine(Environment.CurrentDirectory,"Timelapse.BuildWindows");
|
|
if(Directory.Exists(p))
|
|
{
|
|
Environment.CurrentDirectory=p;
|
|
}
|
|
string? parent=Path.GetDirectoryName(Environment.CurrentDirectory);
|
|
if(!string.IsNullOrWhiteSpace(parent))
|
|
{
|
|
if(Directory.Exists("Output"))
|
|
{
|
|
Directory.Delete("Output",true);
|
|
}
|
|
Directory.CreateDirectory("Output");
|
|
string f = File.ReadAllText("input.txt");
|
|
f=f.Replace("{WORKINGPATH}",parent.TrimEnd('\\') + '\\');
|
|
if(!string.IsNullOrWhiteSpace(nsis))
|
|
{
|
|
File.WriteAllText("x86.nsi",f.Replace("{OutputExeFile}","TimelapseNow-32bit-setup.exe").Replace("win-x64","win-x86").Replace("amd64","x86"));
|
|
File.WriteAllText("x86_64.nsi",f.Replace("{OutputExeFile}","TimelapseNow-64bit-setup.exe"));
|
|
}
|
|
string dir2Zip_x86=Path.Combine(parent,"Timelapse.Windows","bin","Release","net6.0-windows","win-x86","publish");
|
|
string dir2Zip_x64=Path.Combine(parent,"Timelapse.Windows","bin","Release","net6.0-windows","win-x64","publish");
|
|
|
|
RunProcess("dotnet","publish -c Release --self-contained -r win-x86",Path.Combine(parent,"Timelapse.Windows"));
|
|
ZipFile.CreateFromDirectory(dir2Zip_x86,Path.Combine("Output","TimelapseNow-32bit-xcopyable.zip"));
|
|
if(!string.IsNullOrWhiteSpace(nsis))
|
|
{
|
|
RunProcess(nsis,Path.Combine("Timelapse.BuildWindows","x86.nsi"),parent);
|
|
}
|
|
RunProcess("dotnet","publish -c Release --self-contained -r win-x64",Path.Combine(parent,"Timelapse.Windows"));
|
|
ZipFile.CreateFromDirectory(dir2Zip_x64,Path.Combine("Output","TimelapseNow-64bit-xcopyable.zip"));
|
|
if(!string.IsNullOrWhiteSpace(nsis))
|
|
{
|
|
RunProcess(nsis,Path.Combine("Timelapse.BuildWindows","x86_64.nsi"),parent);
|
|
}
|
|
|
|
//makensis
|
|
}
|
|
}
|
|
} |