Skip to content

Commit a1aaabd

Browse files
committed
test target stuff
1 parent e1fa899 commit a1aaabd

File tree

7 files changed

+78
-44
lines changed

7 files changed

+78
-44
lines changed

ElectronNET.CLI/Commands/Actions/GetTargetPlatformInformation.cs

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public struct GetTargetPlatformInformationResult
1414

1515
}
1616

17-
public static GetTargetPlatformInformationResult Do(string desiredPlatform)
17+
public static GetTargetPlatformInformationResult Do(string desiredPlatform, string specifiedPlatfromFromCustom)
1818
{
1919
string netCorePublishRid = string.Empty;
2020
string electronPackerPlatform = string.Empty;
@@ -33,34 +33,27 @@ public static GetTargetPlatformInformationResult Do(string desiredPlatform)
3333
netCorePublishRid = "linux-x64";
3434
electronPackerPlatform = "linux";
3535
break;
36+
case "custom":
37+
var splittedSpecified = specifiedPlatfromFromCustom.Split(';');
38+
netCorePublishRid = splittedSpecified[0];
39+
electronPackerPlatform = splittedSpecified[1];
40+
break;
3641
default:
37-
if (desiredPlatform.StartsWith("custom="))
42+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
3843
{
39-
44+
netCorePublishRid = "win-x64";
45+
electronPackerPlatform = "win32";
4046
}
41-
else
47+
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
4248
{
43-
44-
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
45-
{
46-
desiredPlatform = "win";
47-
netCorePublishRid = "win-x64";
48-
electronPackerPlatform = "win32";
49-
}
50-
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
51-
{
52-
desiredPlatform = "osx";
53-
netCorePublishRid = "osx-x64";
54-
electronPackerPlatform = "darwin";
55-
}
56-
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
57-
{
58-
desiredPlatform = "linux";
59-
netCorePublishRid = "linux-x64";
60-
electronPackerPlatform = "linux";
61-
}
49+
netCorePublishRid = "osx-x64";
50+
electronPackerPlatform = "darwin";
51+
}
52+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
53+
{
54+
netCorePublishRid = "linux-x64";
55+
electronPackerPlatform = "linux";
6256
}
63-
6457

6558
break;
6659
}

ElectronNET.CLI/Commands/BuildCommand.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,17 @@ public Task<bool> ExecuteAsync()
2828
{
2929
Console.WriteLine("Build Electron Application...");
3030

31-
var parsedArgs = _args
32-
.Select(s => s.Split(new[] { ':' }, 1))
33-
.ToDictionary(s => s[0], s => s[1]);
31+
SimpleCommandLineParser parser = new SimpleCommandLineParser();
32+
parser.Parse(_args);
3433

35-
var desiredPlatform = parsedArgs["/target"];
36-
37-
var platformInfo = GetTargetPlatformInformation.Do(desiredPlatform);
34+
var desiredPlatform = parser.Arguments["/target"][0];
35+
string specifiedFromCustom = string.Empty;
36+
if (desiredPlatform == "custom" && parser.Arguments["/target"].Length > 1)
37+
{
38+
specifiedFromCustom = parser.Arguments["/target"][1];
39+
}
40+
41+
var platformInfo = GetTargetPlatformInformation.Do(desiredPlatform, specifiedFromCustom);
3842

3943
Console.WriteLine($"Build ASP.NET Core App for {platformInfo.NetCorePublishRid}...");
4044

ElectronNET.CLI/Commands/StartElectronCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public Task<bool> ExecuteAsync()
4848
Directory.CreateDirectory(tempPath);
4949
}
5050

51-
var platformInfo = GetTargetPlatformInformation.Do(string.Empty);
51+
var platformInfo = GetTargetPlatformInformation.Do(String.Empty, String.Empty);
5252

5353
string tempBinPath = Path.Combine(tempPath, "bin");
5454
var resultCode = ProcessHelper.CmdExecute($"dotnet publish -r {platformInfo.NetCorePublishRid} --output \"{tempBinPath}\"", aspCoreProjectPath);

ElectronNET.CLI/Program.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
namespace ElectronNET.CLI
99
{
10-
1110
class Program
1211
{
1312
static void Main(string[] args)
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using System.Collections.Generic;
2+
3+
namespace ElectronNET.CLI
4+
{
5+
public class SimpleCommandLineParser
6+
{
7+
public SimpleCommandLineParser()
8+
{
9+
Arguments = new Dictionary<string, string[]>();
10+
}
11+
public IDictionary<string, string[]> Arguments { get; private set; }
12+
public void Parse(string[] args)
13+
{
14+
var currentName = "";
15+
var values = new List<string>();
16+
foreach (var arg in args)
17+
{
18+
if (arg.StartsWith("/"))
19+
{
20+
if (currentName != "")
21+
Arguments[currentName] = values.ToArray();
22+
values.Clear();
23+
currentName = arg.Substring(1);
24+
}
25+
else if (currentName == "")
26+
Arguments[arg] = new string[0];
27+
else
28+
values.Add(arg);
29+
}
30+
if (currentName != "")
31+
Arguments[currentName] = values.ToArray();
32+
}
33+
public bool Contains(string name)
34+
{
35+
return Arguments.ContainsKey(name);
36+
}
37+
}
38+
}

buildAll.cmd

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ dotnet build
1616

1717
echo "Invoke electronize build in WebApp Demo"
1818

19-
echo "-- win (dev-build)"
20-
dotnet "../ElectronNET.CLI/bin/Debug/netcoreapp2.0/dotnet-electronize.dll" build /target:win
19+
echo "/target win (dev-build)"
20+
dotnet "../ElectronNET.CLI/bin/Debug/netcoreapp2.0/dotnet-electronize.dll" build /target win
2121

22-
echo "-- linux (dev-build)"
23-
dotnet "../ElectronNET.CLI/bin/Debug/netcoreapp2.0/dotnet-electronize.dll" build /target:linux
22+
echo "/target linux (dev-build)"
23+
dotnet "../ElectronNET.CLI/bin/Debug/netcoreapp2.0/dotnet-electronize.dll" build /target linux
2424

2525
:: Be aware, that for non-electronnet-dev environments the correct
2626
:: invoke command would be dotnet electronize ...
2727

2828
:: Not supported on Windows Systems, because of SymLinks...
29-
:: echo "-- osx"
30-
:: dotnet electronize build osx
29+
:: echo "/target osx"
30+
:: dotnet electronize build /target osx

buildAll.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ dotnet restore
1818
dotnet build
1919

2020
echo "Invoke electronize build in WebApp Demo"
21-
echo "-- win (dev-build)"
22-
dotnet "$dir/ElectronNET.CLI/bin/Debug/netcoreapp2.0/dotnet-electronize.dll" build win
21+
echo "/target win (dev-build)"
22+
dotnet "$dir/ElectronNET.CLI/bin/Debug/netcoreapp2.0/dotnet-electronize.dll" build /target win
2323

24-
echo "-- linux (dev-build)"
25-
dotnet "$dir/ElectronNET.CLI/bin/Debug/netcoreapp2.0/dotnet-electronize.dll" build linux
24+
echo "/target linux (dev-build)"
25+
dotnet "$dir/ElectronNET.CLI/bin/Debug/netcoreapp2.0/dotnet-electronize.dll" build /target linux
2626

27-
echo "-- osx (dev-build)"
28-
dotnet "$dir/ElectronNET.CLI/bin/Debug/netcoreapp2.0/dotnet-electronize.dll" build osx
27+
echo "/target osx (dev-build)"
28+
dotnet "$dir/ElectronNET.CLI/bin/Debug/netcoreapp2.0/dotnet-electronize.dll" build /target osx
2929

3030
# Be aware, that for non-electronnet-dev environments the correct
3131
# invoke command would be dotnet electronize ...

0 commit comments

Comments
 (0)