Skip to content

Fixes Add ability to pass an argument for "Version" for both the "dot… #546

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

Merged
merged 3 commits into from
Jul 1, 2021
Merged
Show file tree
Hide file tree
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
12 changes: 11 additions & 1 deletion ElectronNET.CLI/Commands/BuildCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class BuildCommand : ICommand
"Optional: '/absolute-path to specify and absolute path for output." + Environment.NewLine +
"Optional: '/package-json' to specify a custom package.json file." + Environment.NewLine +
"Optional: '/install-modules' to force node module install. Implied by '/package-json'" + Environment.NewLine +
"Optional: '/Version' to specify the version that should be applied to both the `dotnet publish` and `electron-builder` commands. Implied by '/Version'" + Environment.NewLine +
"Optional: '/p:[property]' or '/property:[property]' to pass in dotnet publish properties. Example: '/property:Version=1.0.0' to override the FileVersion" + Environment.NewLine +
"Full example for a 32bit debug build with electron prune: build /target custom win7-x86;win32 /dotnet-configuration Debug /electron-arch ia32 /electron-params \"--prune=true \"";

Expand All @@ -44,6 +45,7 @@ public BuildCommand(string[] args)
private string _manifest = "manifest";
private string _paramPublishReadyToRun = "PublishReadyToRun";
private string _paramPublishSingleFile = "PublishSingleFile";
private string _paramVersion = "Version";

public Task<bool> ExecuteAsync()
{
Expand All @@ -54,6 +56,11 @@ public Task<bool> ExecuteAsync()
SimpleCommandLineParser parser = new SimpleCommandLineParser();
parser.Parse(_args);

//This version will be shared between the dotnet publish and electron-builder commands
string version = null;
if (parser.Arguments.ContainsKey(_paramVersion))
version = parser.Arguments[_paramVersion][0];

if (!parser.Arguments.ContainsKey(_paramTarget))
{
Console.WriteLine($"Error: missing '{_paramTarget}' argument.");
Expand Down Expand Up @@ -185,7 +192,10 @@ public Task<bool> ExecuteAsync()
manifestFileName = parser.Arguments[_manifest].First();
}

ProcessHelper.CmdExecute($"node build-helper.js " + manifestFileName, tempPath);
ProcessHelper.CmdExecute(
string.IsNullOrWhiteSpace(version)
? $"node build-helper.js {manifestFileName}"
: $"node build-helper.js {manifestFileName} {version}", tempPath);

Console.WriteLine($"Package Electron App for Platform {platformInfo.ElectronPackerPlatform}...");
ProcessHelper.CmdExecute($"npx electron-builder --config=./bin/electron-builder.json --{platformInfo.ElectronPackerPlatform} --{electronArch} -c.electronVersion=11.1.1 {electronParams}", tempPath);
Expand Down
3 changes: 3 additions & 0 deletions ElectronNET.Host/build-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ const dasherize = require('dasherize');
const fs = require('fs');

const builderConfiguration = { ...manifestFile.build };
if(process.argv.length > 3) {
builderConfiguration.buildVersion = process.argv[3];
}
if(builderConfiguration.hasOwnProperty('buildVersion')) {
// @ts-ignore
const packageJson = require('./package');
Expand Down