diff --git a/ElectronNET.CLI/Commands/AddCommand.cs b/ElectronNET.CLI/Commands/AddCommand.cs index f93ea3f..7c12ca7 100644 --- a/ElectronNET.CLI/Commands/AddCommand.cs +++ b/ElectronNET.CLI/Commands/AddCommand.cs @@ -68,6 +68,10 @@ namespace ElectronNET.CLI.Commands EmbeddedFileHelper.DeployEmbeddedFile(targetFilePath, "package.json", "ElectronHostHook."); EmbeddedFileHelper.DeployEmbeddedFile(targetFilePath, "tsconfig.json", "ElectronHostHook."); + // npm for typescript compiler etc. + Console.WriteLine("Start npm install..."); + ProcessHelper.CmdExecute("npm install", targetFilePath); + // search .csproj Console.WriteLine($"Search your .csproj to add configure CopyToPublishDirectory to 'Never'"); var projectFile = Directory.EnumerateFiles(currentDirectory, "*.csproj", SearchOption.TopDirectoryOnly).FirstOrDefault(); diff --git a/ElectronNET.CLI/Commands/BuildCommand.cs b/ElectronNET.CLI/Commands/BuildCommand.cs index 9da0d63..575e3dd 100644 --- a/ElectronNET.CLI/Commands/BuildCommand.cs +++ b/ElectronNET.CLI/Commands/BuildCommand.cs @@ -16,7 +16,7 @@ namespace ElectronNET.CLI.Commands public static string COMMAND_ARGUMENTS = "Needed: '/target' with params 'win/osx/linux' to build for a typical app or use 'custom' and specify .NET Core build config & electron build config" + Environment.NewLine + " for custom target, check .NET Core RID Catalog and Electron build target/" + Environment.NewLine + " e.g. '/target win' or '/target custom \"win7-x86;win32\"'" + Environment.NewLine + - "Optional: '/dotnet-configuration' with the desired .NET Core build config e.g. release or debug. Default = Release" + Environment.NewLine + + "Optional: '/dotnet-configuration' with the desired .NET Core build config e.g. release or debug. Default = Release" + 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 + "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 \""; @@ -86,32 +86,26 @@ namespace ElectronNET.CLI.Commands DeployEmbeddedElectronFiles.Do(tempPath); - var checkForNodeModulesDirPath = Path.Combine(tempPath, "node_modules"); + var nodeModulesDirPath = Path.Combine(tempPath, "node_modules"); - if (Directory.Exists(checkForNodeModulesDirPath) == false) + + Console.WriteLine("node_modules missing in: " + checkForNodeModulesDirPath); + + Console.WriteLine("Start npm install..."); + ProcessHelper.CmdExecute("npm install", tempPath); + + Console.WriteLine("Start npm install electron-packager..."); + + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { - Console.WriteLine("node_modules missing in: " + checkForNodeModulesDirPath); - - Console.WriteLine("Start npm install..."); - ProcessHelper.CmdExecute("npm install", tempPath); - - Console.WriteLine("Start npm install electron-packager..."); - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - // Works proper on Windows... - ProcessHelper.CmdExecute("npm install electron-packager --global", tempPath); - } - else - { - // ToDo: find another solution or document it proper - // GH Issue https://github.com/electron-userland/electron-prebuilt/issues/48 - Console.WriteLine("Electron Packager - make sure you invoke 'sudo npm install electron-packager --global' at " + tempPath + " manually. Sry."); - } + // Works proper on Windows... + ProcessHelper.CmdExecute("npm install electron-packager --global", tempPath); } else { - Console.WriteLine("Skip npm install, because node_modules directory exists in: " + checkForNodeModulesDirPath); + // ToDo: find another solution or document it proper + // GH Issue https://github.com/electron-userland/electron-prebuilt/issues/48 + Console.WriteLine("Electron Packager - make sure you invoke 'sudo npm install electron-packager --global' at " + tempPath + " manually. Sry."); } Console.WriteLine("ElectronHostHook handling started..."); diff --git a/ElectronNET.CLI/Commands/StartElectronCommand.cs b/ElectronNET.CLI/Commands/StartElectronCommand.cs index 93e8510..8e69982 100644 --- a/ElectronNET.CLI/Commands/StartElectronCommand.cs +++ b/ElectronNET.CLI/Commands/StartElectronCommand.cs @@ -61,19 +61,12 @@ namespace ElectronNET.CLI.Commands DeployEmbeddedElectronFiles.Do(tempPath); - var checkForNodeModulesDirPath = Path.Combine(tempPath, "node_modules"); + var nodeModulesDirPath = Path.Combine(tempPath, "node_modules"); - if (Directory.Exists(checkForNodeModulesDirPath) == false) - { - Console.WriteLine("node_modules missing in: " + checkForNodeModulesDirPath); + Console.WriteLine("node_modules missing in: " + nodeModulesDirPath); - Console.WriteLine("Start npm install..."); - ProcessHelper.CmdExecute("npm install", tempPath); - } - else - { - Console.WriteLine("Skip npm install, because node_modules directory exists in: " + checkForNodeModulesDirPath); - } + Console.WriteLine("Start npm install..."); + ProcessHelper.CmdExecute("npm install", tempPath); Console.WriteLine("ElectronHostHook handling started..."); @@ -111,6 +104,6 @@ namespace ElectronNET.CLI.Commands }); } - + } }