Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add /no-restore and SelfContained property support in CLI #847

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/ElectronNET.CLI/Commands/BuildCommand.cs
Original file line number Diff line number Diff line change
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 @@ private Dictionary<string, string> GetDotNetPublishFlags(SimpleCommandLineParser
{
{"/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
Loading