Skip to content

Commit 5338749

Browse files
committed
Fixed extraction of arguments
1 parent 4790c4e commit 5338749

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

ElectronNET.CLI/Commands/BuildCommand.cs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class BuildCommand : ICommand
2323
"Optional: '/install-modules' to force node module install. Implied by '/package-json'" + Environment.NewLine +
2424
"Optional: '/Version' to specify the version that should be applied to both the `dotnet publish` and `electron-builder` commands. Implied by '/Version'" + Environment.NewLine +
2525
"Optional: '/p:[property]' or '/property:[property]' to pass in dotnet publish properties. Example: '/property:Version=1.0.0' to override the FileVersion" + Environment.NewLine +
26-
"Optional: '-- [-a|--arch <ARCHITECTURE>] [-f | --framework<FRAMEWORK>] [--force] [--no-dependencies] [--no-incremental] [--no-restore] [--nologo]" + Environment.NewLine +
26+
"Optional: '/dotnet-publish [-a|--arch <ARCHITECTURE>] [-f | --framework<FRAMEWORK>] [--force] [--no-dependencies] [--no-incremental] [--no-restore] [--nologo]" + Environment.NewLine +
2727
" [--no-self-contained] [--os <OS>] [--self-contained [true|false]] [--source <SOURCE>] [-v|--verbosity <LEVEL>] [--version-suffix <VERSION_SUFFIX>]'" + Environment.NewLine +
2828
" to add additional dot net publish arguments." + Environment.NewLine +
2929
"Full example for a 32bit debug build with electron prune: build /target custom win7-x86;win32 /dotnet-configuration Debug /electron-arch ia32 /electron-params \"--prune=true \"";
@@ -49,6 +49,7 @@ public BuildCommand(string[] args)
4949
private string _paramPublishReadyToRun = "PublishReadyToRun";
5050
private string _paramPublishSingleFile = "PublishSingleFile";
5151
private string _paramVersion = "Version";
52+
private string _paramDotNetPublish = "dotnet-publish";
5253

5354
public Task<bool> ExecuteAsync()
5455
{
@@ -113,7 +114,7 @@ public Task<bool> ExecuteAsync()
113114
$"dotnet publish -r {platformInfo.NetCorePublishRid} -c \"{configuration}\" --output \"{tempBinPath}\" {string.Join(' ', dotNetPublishFlags.Select(kvp => $"{kvp.Key}={kvp.Value}"))}";
114115

115116
// add any additional dotnet flags
116-
var dotnetFlags = GetDotNetArgs(_args);
117+
var dotnetFlags = GetDotNetArgs(parser);
117118
if (dotnetFlags.Any())
118119
{
119120
command += " " + string.Join(" ", dotnetFlags);
@@ -224,19 +225,14 @@ public Task<bool> ExecuteAsync()
224225
{
225226
"--interactive", "-h", "--help"
226227
};
227-
private List<string> GetDotNetArgs(string[] args)
228+
private List<string> GetDotNetArgs(SimpleCommandLineParser parser)
228229
{
229-
if (!args.Contains("--")) return new List<string> { "--self-contained" };
230+
if (!parser.TryGet(_paramDotNetPublish, out var args)) return new List<string> { "--self-contained" };
230231

231232
var list = args
232-
.SkipWhile(i => "--".Equals(i, StringComparison.OrdinalIgnoreCase))
233-
.Skip(1)
234233
.Except(DotNetFlagsToIgnore)
235234
.ToList();
236235

237-
// ensure the args flag is removed
238-
list.Remove("--");
239-
240236
// remove flags that are handled by design
241237
foreach (var flag in DotNetFlagsWithValuesReserved)
242238
{

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,10 @@ electronize build /target custom "win7-x86;win32" /electron-arch ia32
150150

151151
### Additional DotNet Publish Flags
152152

153-
For certain scenarios additional `dotnet publish` arguments may be required. To add additional publish flags use the `--` flag at the end of your command and add any additional publish flags after. For example if you want to skip the default nuget restore you can do that like this:
153+
For certain scenarios additional `dotnet publish` arguments may be required. To add additional publish flags use the `/dotnet-publish` flag and add any additional publish flags after. For example if you want to skip the default nuget restore you can do that like this:
154154

155155
```
156-
electronize build /target osx -- --no-restore
156+
electronize build /target osx /dotnet-publish --no-restore
157157
```
158158

159159
#### Self-Contained

0 commit comments

Comments
 (0)