Skip to content

Commit a2ab76d

Browse files
committed
electron arch and co
1 parent d01d82f commit a2ab76d

File tree

2 files changed

+35
-6
lines changed

2 files changed

+35
-6
lines changed

ElectronNET.CLI/Commands/BuildCommand.cs

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ public BuildCommand(string[] args)
2222
_args = args;
2323
}
2424

25+
private string _paramTarget = "target";
26+
private string _paramDotNetConfig = "dotnet-configuration";
27+
private string _paramElectronArch = "electron-arch";
28+
private string _paramElectronParams = "electron-params";
29+
2530
public Task<bool> ExecuteAsync()
2631
{
2732
return Task.Run(() =>
@@ -31,13 +36,19 @@ public Task<bool> ExecuteAsync()
3136
SimpleCommandLineParser parser = new SimpleCommandLineParser();
3237
parser.Parse(_args);
3338

34-
var desiredPlatform = parser.Arguments["target"][0];
39+
var desiredPlatform = parser.Arguments[_paramTarget][0];
3540
string specifiedFromCustom = string.Empty;
36-
if (desiredPlatform == "custom" && parser.Arguments["target"].Length > 1)
41+
if (desiredPlatform == "custom" && parser.Arguments[_paramTarget].Length > 1)
3742
{
3843
specifiedFromCustom = parser.Arguments["target"][1];
3944
}
40-
45+
46+
string configuration = "Release";
47+
if (parser.Arguments.ContainsKey(_paramDotNetConfig))
48+
{
49+
configuration = parser.Arguments[_paramDotNetConfig][0];
50+
}
51+
4152
var platformInfo = GetTargetPlatformInformation.Do(desiredPlatform, specifiedFromCustom);
4253

4354
Console.WriteLine($"Build ASP.NET Core App for {platformInfo.NetCorePublishRid}...");
@@ -53,9 +64,9 @@ public Task<bool> ExecuteAsync()
5364

5465
string tempBinPath = Path.Combine(tempPath, "bin");
5566

56-
Console.WriteLine($"Build ASP.NET Core App for {platformInfo.NetCorePublishRid}...");
67+
Console.WriteLine($"Build ASP.NET Core App for {platformInfo.NetCorePublishRid} under {configuration}-Configuration...");
5768

58-
var resultCode = ProcessHelper.CmdExecute($"dotnet publish -r {platformInfo.NetCorePublishRid} --output \"{tempBinPath}\"", Directory.GetCurrentDirectory());
69+
var resultCode = ProcessHelper.CmdExecute($"dotnet publish -r {platformInfo.NetCorePublishRid} -c {configuration} --output \"{tempBinPath}\"", Directory.GetCurrentDirectory());
5970

6071
if (resultCode != 0)
6172
{
@@ -99,8 +110,21 @@ public Task<bool> ExecuteAsync()
99110
Console.WriteLine("Executing electron magic in this directory: " + buildPath);
100111

101112
// ToDo: Need a solution for --asar support
113+
114+
string electronArch = "x64";
115+
if (parser.Arguments.ContainsKey(_paramElectronArch))
116+
{
117+
electronArch = parser.Arguments[_paramElectronArch][0];
118+
}
119+
120+
string electronParams = "";
121+
if (parser.Arguments.ContainsKey(_paramElectronParams))
122+
{
123+
electronParams = parser.Arguments[electronParams][0];
124+
}
125+
102126
Console.WriteLine($"Package Electron App for Platform {platformInfo.ElectronPackerPlatform}...");
103-
ProcessHelper.CmdExecute($"electron-packager . --platform={platformInfo.ElectronPackerPlatform} --arch=x64 --out=\"{buildPath}\" --overwrite", tempPath);
127+
ProcessHelper.CmdExecute($"electron-packager . --platform={platformInfo.ElectronPackerPlatform} --arch={electronArch} {electronParams} --out=\"{buildPath}\" --overwrite", tempPath);
104128

105129
Console.WriteLine("... done");
106130

buildAll.cmd

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

1717
echo "Invoke electronize build in WebApp Demo"
1818

19+
20+
echo "/target xxx (dev-build)"
21+
dotnet "../ElectronNET.CLI/bin/Debug/netcoreapp2.0/dotnet-electronize.dll" build /target custom win7-x86;win32 /dotnet-configuration Debug /electron-arch x86 /electron-params "--prune=true "
22+
23+
1924
echo "/target win (dev-build)"
2025
dotnet "../ElectronNET.CLI/bin/Debug/netcoreapp2.0/dotnet-electronize.dll" build /target win
2126

0 commit comments

Comments
 (0)