Skip to content

Commit f3bd3d0

Browse files
Merge pull request #546 from tub5/master
Fixes Add ability to pass an argument for "Version" for both the "dot…
2 parents c1b3d42 + 0e8cfec commit f3bd3d0

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

ElectronNET.CLI/Commands/BuildCommand.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public class BuildCommand : ICommand
2121
"Optional: '/absolute-path to specify and absolute path for output." + Environment.NewLine +
2222
"Optional: '/package-json' to specify a custom package.json file." + Environment.NewLine +
2323
"Optional: '/install-modules' to force node module install. Implied by '/package-json'" + Environment.NewLine +
24+
"Optional: '/Version' to specify the version that should be applied to both the `dotnet publish` and `electron-builder` commands. Implied by '/Version'" + Environment.NewLine +
2425
"Optional: '/p:[property]' or '/property:[property]' to pass in dotnet publish properties. Example: '/property:Version=1.0.0' to override the FileVersion" + Environment.NewLine +
2526
"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 \"";
2627

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

4850
public Task<bool> ExecuteAsync()
4951
{
@@ -54,6 +56,11 @@ public Task<bool> ExecuteAsync()
5456
SimpleCommandLineParser parser = new SimpleCommandLineParser();
5557
parser.Parse(_args);
5658

59+
//This version will be shared between the dotnet publish and electron-builder commands
60+
string version = null;
61+
if (parser.Arguments.ContainsKey(_paramVersion))
62+
version = parser.Arguments[_paramVersion][0];
63+
5764
if (!parser.Arguments.ContainsKey(_paramTarget))
5865
{
5966
Console.WriteLine($"Error: missing '{_paramTarget}' argument.");
@@ -185,7 +192,10 @@ public Task<bool> ExecuteAsync()
185192
manifestFileName = parser.Arguments[_manifest].First();
186193
}
187194

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

190200
Console.WriteLine($"Package Electron App for Platform {platformInfo.ElectronPackerPlatform}...");
191201
ProcessHelper.CmdExecute($"npx electron-builder --config=./bin/electron-builder.json --{platformInfo.ElectronPackerPlatform} --{electronArch} -c.electronVersion=11.1.1 {electronParams}", tempPath);

ElectronNET.Host/build-helper.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ const dasherize = require('dasherize');
55
const fs = require('fs');
66

77
const builderConfiguration = { ...manifestFile.build };
8+
if(process.argv.length > 3) {
9+
builderConfiguration.buildVersion = process.argv[3];
10+
}
811
if(builderConfiguration.hasOwnProperty('buildVersion')) {
912
// @ts-ignore
1013
const packageJson = require('./package');

0 commit comments

Comments
 (0)