Skip to content

Commit

Permalink
feat: introduce /no-restore /no-self-contained CLI args
Browse files Browse the repository at this point in the history
  • Loading branch information
gorsheninmv committed Apr 29, 2024
1 parent d225324 commit bf4be95
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/ElectronNET.CLI/Commands/BuildCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public class BuildCommand : ICommand
" for custom target, check .NET Core RID Catalog and Electron build target/" + Environment.NewLine +
" e.g. '/target win' or '/target custom \"win7-x86;win\"'" + Environment.NewLine +
"Optional: '/dotnet-configuration' with the desired .NET Core build config e.g. release or debug. Default = Release" + Environment.NewLine +
"Optional: '/no-restore' to disable nuget packages restore" + Environment.NewLine +
"Optional: '/no-self-contained' to exclude .NET runtime" + Environment.NewLine +
"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 +
"Optional: '/electron-params' specify any other valid parameter, which will be routed to the electron-packager." + Environment.NewLine +
"Optional: '/relative-path' to specify output a subdirectory for output." + Environment.NewLine +
Expand Down Expand Up @@ -45,6 +47,8 @@ public BuildCommand(string[] args)
private string _manifest = "manifest";
private string _paramPublishReadyToRun = "PublishReadyToRun";
private string _paramPublishSingleFile = "PublishSingleFile";
private string _paramNoRestore = "no-restore";
private string _paramNoSelfContained = "no-self-contained";
private string _paramVersion = "Version";

public Task<bool> ExecuteAsync()
Expand Down Expand Up @@ -81,6 +85,14 @@ public Task<bool> ExecuteAsync()
configuration = parser.Arguments[_paramDotNetConfig][0];
}
string noRestore = parser.Arguments.ContainsKey(_paramNoRestore)
? "--no-restore"
: string.Empty;
string selfContained = parser.Arguments.ContainsKey(_paramNoSelfContained)
? string.Empty
: "--self-contained";
var platformInfo = GetTargetPlatformInformation.Do(desiredPlatform, specifiedFromCustom);
Console.WriteLine($"Build ASP.NET Core App for {platformInfo.NetCorePublishRid}...");
Expand All @@ -107,7 +119,7 @@ public Task<bool> ExecuteAsync()
var dotNetPublishFlags = GetDotNetPublishFlags(parser);
var command =
$"dotnet publish -r {platformInfo.NetCorePublishRid} -c \"{configuration}\" --output \"{tempBinPath}\" {string.Join(' ', dotNetPublishFlags.Select(kvp => $"{kvp.Key}={kvp.Value}"))} --self-contained";
$"dotnet publish -r {platformInfo.NetCorePublishRid} -c \"{configuration}\"{' ' + noRestore} --output \"{tempBinPath}\" {string.Join(' ', dotNetPublishFlags.Select(kvp => $"{kvp.Key}={kvp.Value}"))} {selfContained}";
// output the command
Console.ForegroundColor = ConsoleColor.Green;
Expand Down

0 comments on commit bf4be95

Please sign in to comment.