Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit bf4be95

Browse files
committedApr 29, 2024·
feat: introduce /no-restore /no-self-contained CLI args
1 parent d225324 commit bf4be95

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed
 

‎src/ElectronNET.CLI/Commands/BuildCommand.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ public class BuildCommand : ICommand
1515
" for custom target, check .NET Core RID Catalog and Electron build target/" + Environment.NewLine +
1616
" e.g. '/target win' or '/target custom \"win7-x86;win\"'" + Environment.NewLine +
1717
"Optional: '/dotnet-configuration' with the desired .NET Core build config e.g. release or debug. Default = Release" + Environment.NewLine +
18+
"Optional: '/no-restore' to disable nuget packages restore" + Environment.NewLine +
19+
"Optional: '/no-self-contained' to exclude .NET runtime" + Environment.NewLine +
1820
"Optional: '/electron-arch' to specify the resulting electron processor architecture (e.g. ia86 for x86 builds). Be aware to use the '/target custom' param as well!" + Environment.NewLine +
1921
"Optional: '/electron-params' specify any other valid parameter, which will be routed to the electron-packager." + Environment.NewLine +
2022
"Optional: '/relative-path' to specify output a subdirectory for output." + Environment.NewLine +
@@ -45,6 +47,8 @@ public BuildCommand(string[] args)
4547
private string _manifest = "manifest";
4648
private string _paramPublishReadyToRun = "PublishReadyToRun";
4749
private string _paramPublishSingleFile = "PublishSingleFile";
50+
private string _paramNoRestore = "no-restore";
51+
private string _paramNoSelfContained = "no-self-contained";
4852
private string _paramVersion = "Version";
4953

5054
public Task<bool> ExecuteAsync()
@@ -81,6 +85,14 @@ public Task<bool> ExecuteAsync()
8185
configuration = parser.Arguments[_paramDotNetConfig][0];
8286
}
8387

88+
string noRestore = parser.Arguments.ContainsKey(_paramNoRestore)
89+
? "--no-restore"
90+
: string.Empty;
91+
92+
string selfContained = parser.Arguments.ContainsKey(_paramNoSelfContained)
93+
? string.Empty
94+
: "--self-contained";
95+
8496
var platformInfo = GetTargetPlatformInformation.Do(desiredPlatform, specifiedFromCustom);
8597

8698
Console.WriteLine($"Build ASP.NET Core App for {platformInfo.NetCorePublishRid}...");
@@ -107,7 +119,7 @@ public Task<bool> ExecuteAsync()
107119
var dotNetPublishFlags = GetDotNetPublishFlags(parser);
108120

109121
var command =
110-
$"dotnet publish -r {platformInfo.NetCorePublishRid} -c \"{configuration}\" --output \"{tempBinPath}\" {string.Join(' ', dotNetPublishFlags.Select(kvp => $"{kvp.Key}={kvp.Value}"))} --self-contained";
122+
$"dotnet publish -r {platformInfo.NetCorePublishRid} -c \"{configuration}\"{' ' + noRestore} --output \"{tempBinPath}\" {string.Join(' ', dotNetPublishFlags.Select(kvp => $"{kvp.Key}={kvp.Value}"))} {selfContained}";
111123

112124
// output the command
113125
Console.ForegroundColor = ConsoleColor.Green;

0 commit comments

Comments
 (0)
Please sign in to comment.