Skip to content

Commit f7217b4

Browse files
committed
Add target command line option found in 'build' to 'start' in CLI to support custom targets in development.
1 parent 3dea167 commit f7217b4

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

ElectronNET.CLI/Commands/StartElectronCommand.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public StartElectronCommand(string[] args)
2828
private string _clearCache = "clear-cache";
2929
private string _paramPublishReadyToRun = "PublishReadyToRun";
3030
private string _paramDotNetConfig = "dotnet-configuration";
31+
private string _paramTarget = "target";
3132

3233
public Task<bool> ExecuteAsync()
3334
{
@@ -59,8 +60,6 @@ public Task<bool> ExecuteAsync()
5960
Directory.CreateDirectory(tempPath);
6061
}
6162

62-
var platformInfo = GetTargetPlatformInformation.Do(string.Empty, string.Empty);
63-
6463
string tempBinPath = Path.Combine(tempPath, "bin");
6564
var resultCode = 0;
6665

@@ -74,6 +73,21 @@ public Task<bool> ExecuteAsync()
7473
publishReadyToRun += "true";
7574
}
7675

76+
// If target is specified as a command line argument, use it.
77+
// Format is the same as the build command.
78+
// If target is not specified, autodetect it.
79+
var platformInfo = GetTargetPlatformInformation.Do(string.Empty, string.Empty);
80+
if (parser.Arguments.ContainsKey(_paramTarget))
81+
{
82+
var desiredPlatform = parser.Arguments[_paramTarget][0];
83+
string specifiedFromCustom = string.Empty;
84+
if (desiredPlatform == "custom" && parser.Arguments[_paramTarget].Length > 1)
85+
{
86+
specifiedFromCustom = parser.Arguments[_paramTarget][1];
87+
}
88+
platformInfo = GetTargetPlatformInformation.Do(desiredPlatform, specifiedFromCustom);
89+
}
90+
7791
string configuration = "Debug";
7892
if (parser.Arguments.ContainsKey(_paramDotNetConfig))
7993
{

0 commit comments

Comments
 (0)