Skip to content

Commit fa51cdd

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 9b27075 + c5db735 commit fa51cdd

File tree

16 files changed

+357
-158
lines changed

16 files changed

+357
-158
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
language: csharp
22
mono: none
33
dist: xenial
4-
dotnet: 3.0
4+
dotnet: 3.1
55
before_script:
66
- export PATH="$PATH:/home/travis/.dotnet/tools"
77
script:

Changelog.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
# Not released
22

3+
4+
# Released
5+
36
# 8.31.1
47

58
ElectronNET.API:
69

710
* New Feature: Electron 8.2.3 support, but not all new features (we search contributors)
811

9-
# Released
10-
1112
# 7.30.2
1213

1314
ElectronNET.CLI:

ElectronNET.API/ElectronNET.API.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp3.0</TargetFramework>
4+
<TargetFramework>netcoreapp3.1</TargetFramework>
55
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
66
<PackageOutputPath>..\artifacts</PackageOutputPath>
77
<PackageId>ElectronNET.API</PackageId>

ElectronNET.API/WebHostBuilderExtensions.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Microsoft.AspNetCore.Hosting;
22
using System;
3+
using System.IO;
34

45
namespace ElectronNET.API
56
{
@@ -22,16 +23,27 @@ public static IWebHostBuilder UseElectron(this IWebHostBuilder builder, string[]
2223
{
2324
BridgeSettings.SocketPort = argument.ToUpper().Replace("/ELECTRONPORT=", "");
2425
Console.WriteLine("Use Electron Port: " + BridgeSettings.SocketPort);
25-
} else if(argument.ToUpper().Contains("ELECTRONWEBPORT"))
26+
}
27+
else if (argument.ToUpper().Contains("ELECTRONWEBPORT"))
2628
{
2729
BridgeSettings.WebPort = argument.ToUpper().Replace("/ELECTRONWEBPORT=", "");
2830
}
2931
}
3032

31-
if(HybridSupport.IsElectronActive)
33+
if (HybridSupport.IsElectronActive)
3234
{
33-
builder.UseContentRoot(AppDomain.CurrentDomain.BaseDirectory)
34-
.UseUrls("http://127.0.0.1:" + BridgeSettings.WebPort);
35+
// check for the content folder if its exists in base director otherwise no need to include
36+
// It was used before because we are publishing the project which copies everything to bin folder and contentroot wwwroot was folder there.
37+
// now we have implemented the live reload if app is run using /watch then we need to use the default project path.
38+
if (Directory.Exists($"{AppDomain.CurrentDomain.BaseDirectory}\\wwwroot"))
39+
{
40+
builder.UseContentRoot(AppDomain.CurrentDomain.BaseDirectory)
41+
.UseUrls("http://localhost:" + BridgeSettings.WebPort);
42+
}
43+
else
44+
{
45+
builder.UseUrls("http://localhost:" + BridgeSettings.WebPort);
46+
}
3547
}
3648

3749
return builder;

ElectronNET.CLI/Commands/StartElectronCommand.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,12 @@ public Task<bool> ExecuteAsync()
6060
var platformInfo = GetTargetPlatformInformation.Do(string.Empty, string.Empty);
6161

6262
string tempBinPath = Path.Combine(tempPath, "bin");
63-
var resultCode = ProcessHelper.CmdExecute($"dotnet publish -r {platformInfo.NetCorePublishRid} --output \"{tempBinPath}\" /p:PublishReadyToRun=true --no-self-contained", aspCoreProjectPath);
63+
var resultCode = 0;
64+
65+
if (parser != null && !parser.Arguments.ContainsKey("watch"))
66+
{
67+
resultCode = ProcessHelper.CmdExecute($"dotnet publish -r {platformInfo.NetCorePublishRid} --output \"{tempBinPath}\" /p:PublishReadyToRun=true --no-self-contained", aspCoreProjectPath);
68+
}
6469

6570
if (resultCode != 0)
6671
{
@@ -110,13 +115,19 @@ public Task<bool> ExecuteAsync()
110115
arguments += " --clear-cache=true";
111116
}
112117

118+
if (parser.Arguments.ContainsKey("watch"))
119+
{
120+
arguments += " --watch=true";
121+
}
122+
113123
string path = Path.Combine(tempPath, "node_modules", ".bin");
114124
bool isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
115125

116126
if (isWindows)
117127
{
118128
Console.WriteLine("Invoke electron.cmd - in dir: " + path);
119129
ProcessHelper.CmdExecute(@"electron.cmd ""..\..\main.js"" " + arguments, path);
130+
120131
}
121132
else
122133
{

ElectronNET.CLI/ElectronNET.CLI.csproj

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
55

6-
<TargetFramework>netcoreapp3.0</TargetFramework>
6+
<TargetFramework>netcoreapp3.1</TargetFramework>
77
<AssemblyName>dotnet-electronize</AssemblyName>
88
<ToolCommandName>electronize</ToolCommandName>
99

@@ -29,6 +29,11 @@
2929
<PackageReleaseNotes>Changelog: https://github.com/ElectronNET/Electron.NET/blob/master/Changelog.md</PackageReleaseNotes>
3030
<PackageIcon>PackageIcon.png</PackageIcon>
3131
<PackAsTool>true</PackAsTool>
32+
<StartupObject></StartupObject>
33+
</PropertyGroup>
34+
35+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
36+
<PlatformTarget>AnyCPU</PlatformTarget>
3237
</PropertyGroup>
3338

3439
<ItemGroup>
@@ -37,7 +42,7 @@
3742
</ItemGroup>
3843

3944
<ItemGroup>
40-
<None Include="PackageIcon.png" Pack="true" PackagePath="\"/>
45+
<None Include="PackageIcon.png" Pack="true" PackagePath="\" />
4146
</ItemGroup>
4247

4348
<ItemGroup>

ElectronNET.CLI/Properties/launchSettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"profiles": {
33
"ElectronNET.CLI": {
44
"commandName": "Project",
5-
"commandLineArgs": "build \"C:\\Users\\Gregor\\Documents\\Visual Studio 2017\\Projects\\ElectronNET\\ElectronNET.WebApp\""
5+
"commandLineArgs": "start /project-path \"C:\\Users\\Rizvi\\source\\repos\\Electron.NET\\ElectronNET.WebApp\" /watch"
66
}
77
}
88
}

ElectronNET.Host/api/browserWindows.js

Lines changed: 19 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ElectronNET.Host/api/browserWindows.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ElectronNET.Host/api/browserWindows.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const path = require('path');
33
const windows: Electron.BrowserWindow[] = [];
44
let readyToShowWindowsIds: number[] = [];
55
let window, lastOptions, electronSocket;
6-
6+
let mainWindowURL;
77
export = (socket: SocketIO.Socket, app: Electron.App) => {
88
electronSocket = socket;
99
socket.on('register-browserWindow-ready-to-show', (id) => {
@@ -199,7 +199,19 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
199199
options = { ...options, webPreferences: { nodeIntegration: true } };
200200
}
201201

202-
window = new BrowserWindow(options);
202+
// we dont want to recreate the window when watch is ready.
203+
if (app.commandLine.hasSwitch('watch') && app['mainWindowURL'] === loadUrl) {
204+
window = app['mainWindow'];
205+
if (window) {
206+
window.reload();
207+
windows.push(window);
208+
electronSocket.emit('BrowserWindowCreated', window.id);
209+
return;
210+
}
211+
} else {
212+
window = new BrowserWindow(options);
213+
}
214+
203215
window.on('ready-to-show', () => {
204216
if (readyToShowWindowsIds.includes(window.id)) {
205217
readyToShowWindowsIds = readyToShowWindowsIds.filter(value => value !== window.id);
@@ -245,6 +257,12 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
245257
console.log('auto clear-cache active for new window.');
246258
}
247259

260+
// set main window url
261+
if (app['mainWindowURL'] == undefined || app['mainWindowURL'] == "") {
262+
app['mainWindowURL'] = loadUrl;
263+
app['mainWindow'] = window;
264+
}
265+
248266
windows.push(window);
249267
electronSocket.emit('BrowserWindowCreated', window.id);
250268
});
@@ -744,6 +762,7 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
744762
getWindowById(id).setBrowserView(browserView);
745763
});
746764

765+
747766
function getWindowById(id: number): Electron.BrowserWindow {
748767
for (let index = 0; index < windows.length; index++) {
749768
const element = windows[index];

0 commit comments

Comments
 (0)