test target stuff

This commit is contained in:
Robert Muehsig
2018-02-11 22:24:12 +01:00
parent e1fa8990ef
commit a1aaabd588
7 changed files with 78 additions and 44 deletions

View File

@@ -14,7 +14,7 @@ namespace ElectronNET.CLI.Commands.Actions
}
public static GetTargetPlatformInformationResult Do(string desiredPlatform)
public static GetTargetPlatformInformationResult Do(string desiredPlatform, string specifiedPlatfromFromCustom)
{
string netCorePublishRid = string.Empty;
string electronPackerPlatform = string.Empty;
@@ -33,34 +33,27 @@ namespace ElectronNET.CLI.Commands.Actions
netCorePublishRid = "linux-x64";
electronPackerPlatform = "linux";
break;
case "custom":
var splittedSpecified = specifiedPlatfromFromCustom.Split(';');
netCorePublishRid = splittedSpecified[0];
electronPackerPlatform = splittedSpecified[1];
break;
default:
if (desiredPlatform.StartsWith("custom="))
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
netCorePublishRid = "win-x64";
electronPackerPlatform = "win32";
}
else
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
desiredPlatform = "win";
netCorePublishRid = "win-x64";
electronPackerPlatform = "win32";
}
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
desiredPlatform = "osx";
netCorePublishRid = "osx-x64";
electronPackerPlatform = "darwin";
}
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
desiredPlatform = "linux";
netCorePublishRid = "linux-x64";
electronPackerPlatform = "linux";
}
netCorePublishRid = "osx-x64";
electronPackerPlatform = "darwin";
}
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
netCorePublishRid = "linux-x64";
electronPackerPlatform = "linux";
}
break;
}

View File

@@ -28,13 +28,17 @@ namespace ElectronNET.CLI.Commands
{
Console.WriteLine("Build Electron Application...");
var parsedArgs = _args
.Select(s => s.Split(new[] { ':' }, 1))
.ToDictionary(s => s[0], s => s[1]);
SimpleCommandLineParser parser = new SimpleCommandLineParser();
parser.Parse(_args);
var desiredPlatform = parsedArgs["/target"];
var platformInfo = GetTargetPlatformInformation.Do(desiredPlatform);
var desiredPlatform = parser.Arguments["/target"][0];
string specifiedFromCustom = string.Empty;
if (desiredPlatform == "custom" && parser.Arguments["/target"].Length > 1)
{
specifiedFromCustom = parser.Arguments["/target"][1];
}
var platformInfo = GetTargetPlatformInformation.Do(desiredPlatform, specifiedFromCustom);
Console.WriteLine($"Build ASP.NET Core App for {platformInfo.NetCorePublishRid}...");

View File

@@ -48,7 +48,7 @@ namespace ElectronNET.CLI.Commands
Directory.CreateDirectory(tempPath);
}
var platformInfo = GetTargetPlatformInformation.Do(string.Empty);
var platformInfo = GetTargetPlatformInformation.Do(String.Empty, String.Empty);
string tempBinPath = Path.Combine(tempPath, "bin");
var resultCode = ProcessHelper.CmdExecute($"dotnet publish -r {platformInfo.NetCorePublishRid} --output \"{tempBinPath}\"", aspCoreProjectPath);

View File

@@ -7,7 +7,6 @@ using System.Text;
namespace ElectronNET.CLI
{
class Program
{
static void Main(string[] args)

View File

@@ -0,0 +1,38 @@
using System.Collections.Generic;
namespace ElectronNET.CLI
{
public class SimpleCommandLineParser
{
public SimpleCommandLineParser()
{
Arguments = new Dictionary<string, string[]>();
}
public IDictionary<string, string[]> Arguments { get; private set; }
public void Parse(string[] args)
{
var currentName = "";
var values = new List<string>();
foreach (var arg in args)
{
if (arg.StartsWith("/"))
{
if (currentName != "")
Arguments[currentName] = values.ToArray();
values.Clear();
currentName = arg.Substring(1);
}
else if (currentName == "")
Arguments[arg] = new string[0];
else
values.Add(arg);
}
if (currentName != "")
Arguments[currentName] = values.ToArray();
}
public bool Contains(string name)
{
return Arguments.ContainsKey(name);
}
}
}

View File

@@ -16,15 +16,15 @@ dotnet build
echo "Invoke electronize build in WebApp Demo"
echo "-- win (dev-build)"
dotnet "../ElectronNET.CLI/bin/Debug/netcoreapp2.0/dotnet-electronize.dll" build /target:win
echo "/target win (dev-build)"
dotnet "../ElectronNET.CLI/bin/Debug/netcoreapp2.0/dotnet-electronize.dll" build /target win
echo "-- linux (dev-build)"
dotnet "../ElectronNET.CLI/bin/Debug/netcoreapp2.0/dotnet-electronize.dll" build /target:linux
echo "/target linux (dev-build)"
dotnet "../ElectronNET.CLI/bin/Debug/netcoreapp2.0/dotnet-electronize.dll" build /target linux
:: Be aware, that for non-electronnet-dev environments the correct
:: invoke command would be dotnet electronize ...
:: Not supported on Windows Systems, because of SymLinks...
:: echo "-- osx"
:: dotnet electronize build osx
:: echo "/target osx"
:: dotnet electronize build /target osx

View File

@@ -18,14 +18,14 @@ dotnet restore
dotnet build
echo "Invoke electronize build in WebApp Demo"
echo "-- win (dev-build)"
dotnet "$dir/ElectronNET.CLI/bin/Debug/netcoreapp2.0/dotnet-electronize.dll" build win
echo "/target win (dev-build)"
dotnet "$dir/ElectronNET.CLI/bin/Debug/netcoreapp2.0/dotnet-electronize.dll" build /target win
echo "-- linux (dev-build)"
dotnet "$dir/ElectronNET.CLI/bin/Debug/netcoreapp2.0/dotnet-electronize.dll" build linux
echo "/target linux (dev-build)"
dotnet "$dir/ElectronNET.CLI/bin/Debug/netcoreapp2.0/dotnet-electronize.dll" build /target linux
echo "-- osx (dev-build)"
dotnet "$dir/ElectronNET.CLI/bin/Debug/netcoreapp2.0/dotnet-electronize.dll" build osx
echo "/target osx (dev-build)"
dotnet "$dir/ElectronNET.CLI/bin/Debug/netcoreapp2.0/dotnet-electronize.dll" build /target osx
# Be aware, that for non-electronnet-dev environments the correct
# invoke command would be dotnet electronize ...