Skip to content

Commit 2cd58a4

Browse files
author
Juan Segura
committed
ZXBSInstallar v1.0.0-beta5
ZXBasicStudio v1.7.0
1 parent a1c4d3d commit 2cd58a4

9 files changed

Lines changed: 167 additions & 63 deletions

File tree

ZXBSInstaller.Log/ServiceLayer.cs

Lines changed: 108 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ public static ExternalTool[] GetExternalTools()
260260
int prg = 10;
261261
for (int n = 0; n < max; n++)
262262
{
263-
if(Cancel)
263+
if (Cancel)
264264
{
265265
return null;
266266
}
@@ -889,12 +889,15 @@ private static ExternalTools_Version GetBorielBasicVersion(string exePath)
889889
var fileName = Path.Combine(exePath, "zxbc.exe");
890890
if (!File.Exists(fileName))
891891
{
892-
fileName = Path.Combine(exePath, "zxbc");
892+
fileName = Path.Combine(exePath, "zxbc.py");
893893
}
894894
if (!File.Exists(fileName))
895895
{
896896
return null;
897897
}
898+
return GetVersionFromParameter(fileName);
899+
900+
#if OLD
898901
// Launch "zxbc.exe --version"
899902
ProcessStartInfo psi = new ProcessStartInfo
900903
{
@@ -928,60 +931,108 @@ private static ExternalTools_Version GetBorielBasicVersion(string exePath)
928931
Version = version,
929932
VersionNumber = number
930933
};
934+
#endif
931935
}
932936
catch (Exception ex)
933937
{
934938
ShowMessage($"Error getting local Boriel Basic version.\r\n{ex.Message}{ex.StackTrace}");
935939
return null;
936940
}
937-
938941
}
939942

940943

941944
private static ExternalTools_Version GetZXBSVersion(string exePath)
942945
{
943946
try
944947
{
945-
var fileName = Path.Combine(exePath, "ZXBasicStudio.exe");
948+
var fileName = Path.Combine(exePath, "version.txt");
946949
if (!File.Exists(fileName))
947950
{
948-
fileName = Path.Combine(exePath, "ZXBasicStudio");
951+
if(File.Exists(Path.Combine(exePath, "ZXBasicStudio.exe"))
952+
|| File.Exists(Path.Combine(exePath, "ZXBasicStudio")))
953+
{
954+
return new ExternalTools_Version()
955+
{
956+
DownloadUrl = "",
957+
BetaNumber = 0,
958+
OperatingSystem = OperatingSystems.All,
959+
Version = "OLD version",
960+
VersionNumber = 0
961+
};
962+
}
963+
return null;
949964
}
965+
var txt = File.ReadAllText(fileName);
966+
var v = GetVersionNumber(txt);
967+
968+
var version = new ExternalTools_Version()
969+
{
970+
DownloadUrl = "",
971+
BetaNumber = v.Item2,
972+
OperatingSystem = OperatingSystems.All,
973+
Version = txt,
974+
VersionNumber = v.Item1
975+
};
976+
return version;
977+
}
978+
catch (Exception ex)
979+
{
980+
ShowMessage($"Error getting local ZXBS version.\r\n{ex.Message}{ex.StackTrace}");
981+
return null;
982+
}
983+
}
984+
985+
986+
/// <summary>
987+
/// Get version from file using --version parameter
988+
/// </summary>
989+
/// <param name="fileName">Executable filename</param>
990+
/// <returns>ExternalTools_Version with the version info</returns>
991+
private static ExternalTools_Version GetVersionFromParameter(string fileName)
992+
{
993+
try
994+
{
950995
if (!File.Exists(fileName))
951996
{
952997
return null;
953998
}
954999

955-
var fvi = FileVersionInfo.GetVersionInfo(fileName);
956-
if (fvi != null)
1000+
ProcessStartInfo psi = new ProcessStartInfo
9571001
{
958-
// Major, minor, Build, private
959-
var version = $"{fvi.ProductMajorPart}.{fvi.ProductMinorPart}.{fvi.ProductBuildPart}";
960-
if (fvi.ProductPrivatePart > 0)
961-
{
962-
version += $"-beta{fvi.ProductPrivatePart}";
963-
}
964-
if (version == "1.0.0")
965-
{
966-
version = "1.6.0-beta6.3";
967-
}
968-
var v = GetVersionNumber(version);
969-
var versionNumber = v.Item1;
970-
var beta = v.Item2;
971-
return new ExternalTools_Version()
972-
{
973-
DownloadUrl = "",
974-
BetaNumber = beta,
975-
OperatingSystem = OperatingSystems.All,
976-
Version = version,
977-
VersionNumber = versionNumber
978-
};
1002+
FileName = fileName,
1003+
Arguments = "--version",
1004+
RedirectStandardOutput = true,
1005+
RedirectStandardError = true,
1006+
UseShellExecute = false,
1007+
CreateNoWindow = true
1008+
};
1009+
using Process process = new Process { StartInfo = psi };
1010+
process.Start();
1011+
string output = process.StandardOutput.ReadToEnd();
1012+
string error = process.StandardError.ReadToEnd();
1013+
process.WaitForExit();
1014+
1015+
if (string.IsNullOrEmpty(output))
1016+
{
1017+
return null;
9791018
}
980-
return null;
1019+
var version = output.Replace("zxbc.py ", "").Replace("\n", "").Replace("\r", "").Replace("v", "");
1020+
var v = GetVersionNumber(version);
1021+
int number = v.Item1;
1022+
int beta = v.Item2;
1023+
1024+
return new ExternalTools_Version()
1025+
{
1026+
DownloadUrl = "",
1027+
BetaNumber = beta,
1028+
OperatingSystem = OperatingSystems.All,
1029+
Version = version,
1030+
VersionNumber = number
1031+
};
9811032
}
9821033
catch (Exception ex)
9831034
{
984-
ShowMessage($"Error getting local ZXBS version.\r\n{ex.Message}{ex.StackTrace}");
1035+
ShowMessage($"Error getting local Boriel Basic version.\r\n{ex.Message}{ex.StackTrace}");
9851036
return null;
9861037
}
9871038
}
@@ -1160,7 +1211,7 @@ echo on
11601211
{
11611212
bashFile = Path.Combine(GeneralConfig.BasePath, "downloads", "zxbsinstall.sh");
11621213
bash = @"
1163-
#!/bin/bash
1214+
# !/bin/bash
11641215
set -e
11651216
11661217
echo ""Updating installer...""
@@ -1247,39 +1298,40 @@ exit 1
12471298

12481299
private static void ExtractFile(string archive, string destination)
12491300
{
1250-
try {
1251-
if (archive.ToLower().EndsWith(".zip"))
1252-
{
1253-
System.IO.Compression.ZipFile.ExtractToDirectory(archive, destination, true);
1254-
}
1255-
else if (CurrentOperatingSystem != OperatingSystems.Windows)
1301+
try
12561302
{
1257-
Directory.CreateDirectory(destination);
1258-
1259-
var psi = new ProcessStartInfo
1303+
if (archive.ToLower().EndsWith(".zip"))
12601304
{
1261-
FileName = "tar",
1262-
Arguments = $"-xzf \"{archive}\" -C \"{destination}\"",
1263-
RedirectStandardOutput = true,
1264-
RedirectStandardError = true,
1265-
UseShellExecute = false,
1266-
CreateNoWindow = true
1267-
};
1305+
System.IO.Compression.ZipFile.ExtractToDirectory(archive, destination, true);
1306+
}
1307+
else if (CurrentOperatingSystem != OperatingSystems.Windows)
1308+
{
1309+
Directory.CreateDirectory(destination);
12681310

1269-
using var process = Process.Start(psi)!;
1311+
var psi = new ProcessStartInfo
1312+
{
1313+
FileName = "tar",
1314+
Arguments = $"-xzf \"{archive}\" -C \"{destination}\"",
1315+
RedirectStandardOutput = true,
1316+
RedirectStandardError = true,
1317+
UseShellExecute = false,
1318+
CreateNoWindow = true
1319+
};
12701320

1271-
string stdout = process.StandardOutput.ReadToEnd();
1272-
string stderr = process.StandardError.ReadToEnd();
1321+
using var process = Process.Start(psi)!;
12731322

1274-
process.WaitForExit();
1323+
string stdout = process.StandardOutput.ReadToEnd();
1324+
string stderr = process.StandardError.ReadToEnd();
12751325

1276-
if (process.ExitCode != 0)
1277-
{
1278-
ShowMessage($"Error unpacking file {archive}\r\n{stderr}");
1279-
return;
1326+
process.WaitForExit();
1327+
1328+
if (process.ExitCode != 0)
1329+
{
1330+
ShowMessage($"Error unpacking file {archive}\r\n{stderr}");
1331+
return;
1332+
}
12801333
}
12811334
}
1282-
}
12831335
catch (Exception ex)
12841336
{
12851337
ShowMessage($"Error unpacking file {archive} on {destination}.\r\n{ex.Message}{ex.StackTrace}");

ZXBSInstaller/Controls/MainControl.axaml.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,8 @@ private void UpdateSummary()
198198
pnlSummary.Children.Add(new TextBlock()
199199
{
200200
Text = ServiceLayer.GeneralConfig.BasePath,
201-
Margin = new Thickness(10, 4, 0, 0)
201+
Margin = new Thickness(10, 4, 0, 0),
202+
TextWrapping = TextWrapping.Wrap
202203
});
203204
}
204205
foreach (var tool in toolItemControls)
@@ -211,12 +212,14 @@ private void UpdateSummary()
211212
{
212213
Text = tool.ExternalTool.Name + ":",
213214
Margin = new Thickness(0, 8, 0, 0),
214-
Foreground = Yellow
215+
Foreground = Yellow,
216+
TextWrapping = TextWrapping.Wrap
215217
});
216218
pnlSummary.Children.Add(new TextBlock()
217219
{
218220
Text = System.IO.Path.Combine(ServiceLayer.GeneralConfig.BasePath, tool.ExternalTool.Id),
219-
Margin = new Thickness(10, 4, 0, 0)
221+
Margin = new Thickness(10, 4, 0, 0),
222+
TextWrapping = TextWrapping.Wrap
220223
});
221224
}
222225
}

ZXBSInstaller/Program.cs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,33 @@
11
using Avalonia;
2+
using Avalonia.OpenGL;
23
using System;
4+
using System.IO;
5+
using System.Linq;
36

47
namespace ZXBSInstaller
58
{
69
internal class Program
710
{
11+
public static string Version = "";
12+
813
// Initialization code. Don't use any Avalonia, third-party APIs or any
914
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
1015
// yet and stuff might break.
1116
[STAThread]
12-
public static void Main(string[] args) => BuildAvaloniaApp()
13-
.StartWithClassicDesktopLifetime(args);
17+
public static void Main(string[] args)
18+
{
19+
var assembly = System.Reflection.Assembly.GetEntryAssembly();
20+
var version = assembly.GetName().Version;
21+
Version = $"{version.Major}.{version.Minor}.{version.Build}.{version.Revision}";
22+
23+
if (args.Contains("--version"))
24+
{
25+
Console.WriteLine($"{Version}");
26+
return;
27+
}
28+
29+
BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
30+
}
1431

1532
// Avalonia configuration, don't remove; also used by visual designer.
1633
public static AppBuilder BuildAvaloniaApp()
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"profiles": {
3+
"ZXBSInstaller": {
4+
"commandName": "Project"
5+
},
6+
"WSL": {
7+
"commandName": "WSL2",
8+
"distributionName": ""
9+
}
10+
}
11+
}

ZXBSInstaller/ZXBSInstaller.csproj

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66
<ApplicationManifest>app.manifest</ApplicationManifest>
77
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
88
<ApplicationIcon>zxbs.ico</ApplicationIcon>
9-
<Version>1.0.0.4</Version>
9+
<Version>1.0.0.5</Version>
1010
</PropertyGroup>
1111
<ItemGroup>
1212
<None Remove="Assets\cancel.svg" />
1313
<None Remove="Assets\install.svg" />
1414
<None Remove="Assets\play.svg" />
1515
<None Remove="Assets\refresh.svg" />
16+
<None Remove="version.txt" />
1617
</ItemGroup>
1718
<ItemGroup>
1819
<AvaloniaResource Include="Assets\cancel.svg" />
@@ -51,4 +52,10 @@
5152
<ProjectReference Include="..\MsBox.Avalonia\MsBox.Avalonia.csproj" />
5253
<ProjectReference Include="..\ZXBSInstaller.Log\ZXBSInstaller.Log.csproj" />
5354
</ItemGroup>
55+
56+
<ItemGroup>
57+
<Content Include="version.txt">
58+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
59+
</Content>
60+
</ItemGroup>
5461
</Project>

ZXBSInstaller/version.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.0.0.5

ZXBStudio/Program.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using Newtonsoft.Json;
44
using System;
55
using System.Diagnostics;
6+
using System.Linq;
67

78
namespace ZXBasicStudio
89
{
@@ -39,13 +40,20 @@ public static string VersionDate { get
3940
[STAThread]
4041
public static void Main(string[] args)
4142
{
43+
SetVersion();
44+
45+
if (args.Contains("--version"))
46+
{
47+
Console.WriteLine($"{Version}");
48+
return;
49+
}
50+
4251
JsonConvert.DefaultSettings = () => new JsonSerializerSettings
4352
{
4453
Formatting= Formatting.Indented,
4554
TypeNameHandling = TypeNameHandling.Auto,
4655
};
4756

48-
SetVersion();
4957

5058
BuildAvaloniaApp()
5159
.StartWithClassicDesktopLifetime(args);

ZXBStudio/ZXBasicStudio.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@
285285
<None Remove="Svg\White\ZX.svg" />
286286
<None Remove="Svg\White\ZXBS.svg" />
287287
<None Remove="Svg\x-svgrepo-com.svg" />
288+
<None Remove="version.txt" />
288289
</ItemGroup>
289290
<ItemGroup>
290291
<AvaloniaResource Include="Assets\asmFile.png" />
@@ -555,6 +556,9 @@
555556
<Content Include="Resources\sysvars.inc">
556557
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
557558
</Content>
559+
<Content Include="version.txt">
560+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
561+
</Content>
558562
<Content Include="zxbs.ico" />
559563
</ItemGroup>
560564

ZXBStudio/version.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.7.0.0

0 commit comments

Comments
 (0)