Skip to content

Commit 7b7c6b8

Browse files
committed
fixes
1 parent 09be5e9 commit 7b7c6b8

File tree

4 files changed

+30
-16
lines changed

4 files changed

+30
-16
lines changed

Builder/Compiler.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,13 @@ public static byte[] Compile(Dictionary<string, string> datamap, byte[] script)
5050
if (value.StartsWith("# ") && value.EndsWith(" #"))
5151
{
5252
string key = value.Substring(2, value.Length - 4).Trim();
53+
#pragma warning disable CS8600 // Converting null literal or possible null value to non-nullable type.
5354
if (datamap.TryGetValue(key, out string newVal))
5455
{
5556
Console.WriteLine($"Replaced: '{value}' -> '{newVal}'");
5657
instr.Operand = newVal;
5758
}
59+
#pragma warning restore CS8600 // Converting null literal or possible null value to non-nullable type.
5860
}
5961
}
6062
}

Builder/GlobalSuppressions.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// This file is used by Code Analysis to maintain SuppressMessage
2+
// attributes that are applied to this project.
3+
// Project-level suppressions either have no target or are given
4+
// a specific target and scoped to a namespace, type, member, etc.
5+
6+
using System.Diagnostics.CodeAnalysis;
7+
8+
[assembly: SuppressMessage("Interoperability", "CA1416:Validate platform compatibility", Justification = "<Pending>", Scope = "member", Target = "~M:Builder.MainForm.#ctor")]

Builder/MainForm.cs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -369,20 +369,15 @@ private void BtnCompile_Click(object? sender, EventArgs e)
369369
// attempt to apply icon if specified
370370
if (!string.IsNullOrWhiteSpace(selectedIconPath))
371371
{
372-
try
372+
bool ok = Compiler.ApplyIcon(sfd.FileName, selectedIconPath);
373+
if (!ok)
373374
{
374-
bool ok = Compiler.ApplyIcon(sfd.FileName, selectedIconPath);
375-
if (!ok)
376-
{
377-
MessageBox.Show(this, "Failed to apply icon to the produced EXE.", "Icon error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
378-
}
379-
}
380-
catch (Exception ex)
381-
{
382-
Console.WriteLine($"[!] Error applying icon: {ex.Message}");
383375
MessageBox.Show(this, "Failed to apply icon to the produced EXE.", "Icon error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
384376
}
385377
}
378+
379+
// Done
380+
MessageBox.Show(this, "File saved as: " + sfd.FileName, "Done", MessageBoxButtons.OK, MessageBoxIcon.Information);
386381
}
387382

388383
}

Stub/Program.cs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ private static string PythonDirectory
6363
{
6464
get
6565
{
66-
if (_appdir == null)
66+
if (_appdir == null && Script != null)
6767
{
6868
using (MD5 md5 = MD5.Create())
6969
{
@@ -100,11 +100,7 @@ private static string PipUrl
100100
}
101101
}
102102

103-
private static string ScriptDirectory = Path.Combine(PythonDirectory, "module");
104-
private static string PythonBinary = Path.Combine(PythonDirectory, "python.exe");
105-
private static string PythonWBinary = Path.Combine(PythonDirectory, "pythonw.exe");
106-
private static string PipBinary = Path.Combine(PythonDirectory, "Scripts", "pip.exe");
107-
private static string PipTempScript = Path.Combine(PythonDirectory, "get-pip.py");
103+
108104

109105
#endregion
110106

@@ -243,12 +239,24 @@ private static void UnzipFromBytes(byte[] zipData, string destination)
243239
private static void Main(string[] args)
244240
{
245241
// Create temp directory if not exists
242+
if (string.IsNullOrEmpty(PythonDirectory))
243+
{
244+
Print.Error("Could not determine temporary directory.");
245+
Environment.Exit(1);
246+
}
247+
248+
// Create directory
246249
if (!Directory.Exists(PythonDirectory))
247250
{
248251
Print.Info("Creating directory: " + PythonDirectory);
249252
Directory.CreateDirectory(PythonDirectory);
250253
}
251254

255+
string PythonBinary = Path.Combine(PythonDirectory, "python.exe");
256+
string PythonWBinary = Path.Combine(PythonDirectory, "pythonw.exe");
257+
string PipBinary = Path.Combine(PythonDirectory, "Scripts", "pip.exe");
258+
string PipTempScript = Path.Combine(PythonDirectory, "get-pip.py");
259+
252260
// Python installer
253261
if (!File.Exists(PythonBinary) || !File.Exists(PythonWBinary))
254262
{
@@ -297,6 +305,7 @@ private static void Main(string[] args)
297305
}
298306

299307
// Extract script
308+
string ScriptDirectory = Path.Combine(PythonDirectory, "module");
300309
if (!File.Exists(Path.Combine(ScriptDirectory, "__main__.py")))
301310
{
302311
UnzipFromBytes(Script, ScriptDirectory);

0 commit comments

Comments
 (0)