Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 511f1eb9 authored by Harald MARTINI's avatar Harald MARTINI
Browse files

removed possibility to select .net version via command line, pass commandline...

removed possibility to select .net version via command line, pass commandline arguments to launched console application
parent f3824483
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,9 @@
{
class Program
{
static void Main(string[] args) => StarterHelper.StartVECTO(args);
static void Main(string[] args)
{
StarterHelper.StartVECTO(args, true);
}
}
}
\ No newline at end of file
......@@ -9,7 +9,7 @@ namespace TUGraz.VECTO
{
try {
// mk20220707: hashing tool currently only works under net45, therefore we hardcoded the version
StarterHelper.StartVECTO(new[]{"net45"});
StarterHelper.StartVECTO(args);
} catch (Exception e) {
MessageBox.Show(e.Message);
}
......
......@@ -4,6 +4,9 @@ namespace TUGraz.VECTO
{
class Program
{
static void Main(string[] args) => StarterHelper.StartVECTO(args);
static void Main(string[] args)
{
StarterHelper.StartVECTO(args, true);
}
}
}
......@@ -3,30 +3,53 @@ using System;
using System.Collections;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
namespace TUGraz.VECTO
{
class StarterHelper
{
public static void StartVECTO(string[] args, params string[] validVersions)
public static void StartVECTO(string[] cmdArguments, params string[] validVersions)
{
StartVECTO(cmdArguments, false, validVersions);
}
public static void StartVECTO(string[] cmdArguments, bool consoleApp, params string[] validVersions)
{
var path = "No path found.";
string version = "No version found.";
if (validVersions is null || validVersions.Length == 0) {
validVersions = new[] { "net45", "net48", "net60" };
}
//var versionArgument = cmdArguments.FirstOrDefault(arg => arg.StartsWith("net"));
try {
if (args.Length > 0) {
version = args[0].ToLower();
} else {
version = GetHighestNETVersion();
}
version = GetHighestNETVersion();
path = $"{version}\\{Assembly.GetExecutingAssembly().GetName().Name}.exe";
Process.Start(new ProcessStartInfo(path) {
WorkingDirectory = Directory.GetCurrentDirectory()
});
string argumentsString = "";
if (cmdArguments.Length > 0) {
foreach (var cmdArgument in cmdArguments) {
argumentsString += "\"" + cmdArgument + "\" ";
}
}
var processInfo = new ProcessStartInfo(path) {
WorkingDirectory = Directory.GetCurrentDirectory(),
Arguments = argumentsString,
};
if (consoleApp) {
processInfo.UseShellExecute = consoleApp ? false : processInfo.UseShellExecute;
Process.Start(processInfo)?.WaitForExit();
} else {
Process.Start(processInfo);
}
ValidateVersion(version, validVersions);
} catch (Exception e) {
var message = $"Error during starting VECTO.\nDetected .NET version: {version}\nTried to open path: {path}\n{e.Message}";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment