diff --git a/ElectronNET.CLI/Commands/BuildCommand.cs b/ElectronNET.CLI/Commands/BuildCommand.cs index 7b10a467..b9775040 100644 --- a/ElectronNET.CLI/Commands/BuildCommand.cs +++ b/ElectronNET.CLI/Commands/BuildCommand.cs @@ -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 \""; @@ -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 ExecuteAsync() { @@ -54,6 +56,11 @@ public Task 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."); @@ -185,7 +192,10 @@ public Task 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); diff --git a/ElectronNET.Host/build-helper.js b/ElectronNET.Host/build-helper.js index e35ac160..d8ebc944 100644 --- a/ElectronNET.Host/build-helper.js +++ b/ElectronNET.Host/build-helper.js @@ -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');