Private Sub BuildRunner As ResumableSub
If Windows Then
Dim FileName As String = ExeName
Dim target As String = "winexe"
Dim output As String = ExeName
File.WriteString(TempFolder, "runner.cs", $"
using System;
using System.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;
using System.IO;
namespace B4JRunner
{
class Program
{
static void Main(string[] args)
{
Process p = new Process();
p.StartInfo.FileName = "${FileName}";
p.StartInfo.WorkingDirectory = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "bin");
p.StartInfo.Arguments = "@release_java_modules.txt -m ${TargetModule}/${PackageName}.main";
foreach (string a in args)
p.StartInfo.Arguments += " " + "\"" + Regex.Replace(a, @"(\\+)$", @"${"$1$1"}") + "\"";
p.Start();
}
}
}"$)
If IconFile = "" Then
File.Copy(File.DirAssets, "icon.ico", TempFolder, "icon.ico")
Else
File.Copy(IconFile, "", TempFolder, "icon.ico")
End If
Wait For (RunShell(True, NetFrameworkCSC , Array($"/target:${target}"$, "/win32icon:icon.ico", $"/out:build\${output}"$, "runner.cs"))) complete (output As String)
File.WriteString(TempFolder, "build\run_debug.bat", $"
cd bin
java.exe @release_java_modules.txt -m ${TargetModule}/${PackageName}.main
pause
"$)
File.Copy(File.Combine(TempFolder, "build/bin"), "javaw.exe", File.Combine(TempFolder, "build/bin"), ExeName)
Else
File.WriteString(TempFolder, "build/run.command", $"#!/bin/bash
cd -- "${"$"}(dirname -- "${"$"}BASH_SOURCE")"
cd bin
./java @release_java_modules.txt -m ${TargetModule}/${PackageName}.main
exit 0
"$)
Dim jo As JavaObject
jo.InitializeNewInstance("java.io.File", Array As String(File.Combine(TempFolder, "build/run.command")))
jo.RunMethod("setExecutable", Array As Object(True, False))
End If
Return True
End Sub