Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6472f34

Browse files
authored
Merge pull request #847 from gorsheninmv/feat-introduce-new-cli-args
Add /no-restore and SelfContained property support in CLI
2 parents 6182320 + 91714f5 commit 6472f34

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/ElectronNET.CLI/Commands/BuildCommand.cs

+9-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ 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 +
1819
"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 +
1920
"Optional: '/electron-params' specify any other valid parameter, which will be routed to the electron-packager." + Environment.NewLine +
2021
"Optional: '/relative-path' to specify output a subdirectory for output." + Environment.NewLine +
@@ -45,6 +46,8 @@ public BuildCommand(string[] args)
4546
private string _manifest = "manifest";
4647
private string _paramPublishReadyToRun = "PublishReadyToRun";
4748
private string _paramPublishSingleFile = "PublishSingleFile";
49+
private string _paramSelfContained = "SelfContained";
50+
private string _paramNoRestore = "no-restore";
4851
private string _paramVersion = "Version";
4952

5053
public Task<bool> ExecuteAsync()
@@ -81,6 +84,10 @@ public Task<bool> ExecuteAsync()
8184
configuration = parser.Arguments[_paramDotNetConfig][0];
8285
}
8386

87+
string noRestore = parser.Arguments.ContainsKey(_paramNoRestore)
88+
? " --no-restore"
89+
: string.Empty;
90+
8491
var platformInfo = GetTargetPlatformInformation.Do(desiredPlatform, specifiedFromCustom);
8592

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

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

112119
// output the command
113120
Console.ForegroundColor = ConsoleColor.Green;
@@ -212,6 +219,7 @@ private Dictionary<string, string> GetDotNetPublishFlags(SimpleCommandLineParser
212219
{
213220
{"/p:PublishReadyToRun", parser.TryGet(_paramPublishReadyToRun, out var rtr) ? rtr[0] : "true"},
214221
{"/p:PublishSingleFile", parser.TryGet(_paramPublishSingleFile, out var psf) ? psf[0] : "true"},
222+
{"/p:SelfContained", parser.TryGet(_paramSelfContained, out var sc) ? sc[0] : "true"},
215223
};
216224

217225
if (parser.Arguments.ContainsKey(_paramVersion))

0 commit comments

Comments
 (0)