Skip to content

Commit

Permalink
Merge pull request #847 from gorsheninmv/feat-introduce-new-cli-args
Browse files Browse the repository at this point in the history
Add /no-restore and SelfContained property support in CLI
  • Loading branch information
FlorianRappl committed Apr 29, 2024
2 parents 6182320 + 91714f5 commit 6472f34
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/ElectronNET.CLI/Commands/BuildCommand.cs
Expand Up @@ -15,6 +15,7 @@ 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: '/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 +46,8 @@ public BuildCommand(string[] args)
private string _manifest = "manifest";
private string _paramPublishReadyToRun = "PublishReadyToRun";
private string _paramPublishSingleFile = "PublishSingleFile";
private string _paramSelfContained = "SelfContained";
private string _paramNoRestore = "no-restore";
private string _paramVersion = "Version";

public Task<bool> ExecuteAsync()
Expand Down Expand Up @@ -81,6 +84,10 @@ public Task<bool> ExecuteAsync()
configuration = parser.Arguments[_paramDotNetConfig][0];
}
string noRestore = parser.Arguments.ContainsKey(_paramNoRestore)
? " --no-restore"
: string.Empty;
var platformInfo = GetTargetPlatformInformation.Do(desiredPlatform, specifiedFromCustom);
Console.WriteLine($"Build ASP.NET Core App for {platformInfo.NetCorePublishRid}...");
Expand All @@ -107,7 +114,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}"))}";
// output the command
Console.ForegroundColor = ConsoleColor.Green;
Expand Down Expand Up @@ -212,6 +219,7 @@ public Task<bool> ExecuteAsync()
{
{"/p:PublishReadyToRun", parser.TryGet(_paramPublishReadyToRun, out var rtr) ? rtr[0] : "true"},
{"/p:PublishSingleFile", parser.TryGet(_paramPublishSingleFile, out var psf) ? psf[0] : "true"},
{"/p:SelfContained", parser.TryGet(_paramSelfContained, out var sc) ? sc[0] : "true"},
};

if (parser.Arguments.ContainsKey(_paramVersion))
Expand Down

0 comments on commit 6472f34

Please sign in to comment.