Add ElectronNET.ConsoleApp test project

This commit is contained in:
softworkz
2025-10-13 14:25:57 +02:00
parent 40d6558613
commit 43ce20d60f
10 changed files with 238 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 273 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@@ -0,0 +1,77 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<!-- When this is enabled, the project will be switched from nuget packages to consuming the ElectronNet orchestration directly -->
<ElectronNetDevMode>False</ElectronNetDevMode>
</PropertyGroup>
<Import Project="..\ElectronNET\build\ElectronNET.props" Condition="$(ElectronNetDevMode)" />
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<OutputType>exe</OutputType>
</PropertyGroup>
<PropertyGroup>
<IsPackable>false</IsPackable>
<ImportNuGetBuildTasksPackTargetsFromSdk>false</ImportNuGetBuildTasksPackTargetsFromSdk>
<PublishTrimmed>False</PublishTrimmed>
<NuGetAudit>False</NuGetAudit>
</PropertyGroup>
<PropertyGroup Label="ElectronNetCommon">
<PackageIcon>128.png</PackageIcon>
<ApplicationIcon>app.ico</ApplicationIcon>
<NoWin32Manifest>true</NoWin32Manifest>
<ElectronIcon>app.ico</ElectronIcon>
<Title>ElectronNET API Demo1</Title>
<Version>1.0.2</Version>
<Product>com.electronnet-apisamples.app</Product>
<Description>Electron.NET Demo Application</Description>
<Company>Electron.Net</Company>
<Copyright>Copyright © 2025, Electron.NET</Copyright>
<PackageTags>Electron;.NET;ASP;NET;Sample;App</PackageTags>
<ElectronVersion>30.4.0</ElectronVersion>
<ElectronSplashScreen></ElectronSplashScreen>
<License>MIT</License>
<TypeScriptModuleKind>commonjs</TypeScriptModuleKind>
<ElectronSingleInstance>False</ElectronSingleInstance>
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
</PropertyGroup>
<ItemGroup>
<Compile Remove="bin\**" />
<Compile Remove="publish\**" />
<Content Remove="publish\**" />
<EmbeddedResource Remove="bin\**" />
<EmbeddedResource Remove="publish\**" />
<None Remove="bin\**" />
<None Remove="publish\**" />
</ItemGroup>
<ItemGroup>
<None Update="Assets\electron.ico">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Assets\electron_32x32.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Compile Remove="obj\**" />
<Compile Remove="publish\**" />
<Content Remove="publish\**" />
<EmbeddedResource Remove="obj\**" />
<EmbeddedResource Remove="publish\**" />
<None Remove="obj\**" />
<None Remove="publish\**" />
<TypeScriptCompile Remove="bin\**" />
<TypeScriptCompile Remove="obj\**" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ElectronNET.API\ElectronNET.API.csproj" Condition="$(ElectronNetDevMode)" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="ElectronNET.Core" Version="0.0.18" Condition="'$(ElectronNetDevMode)' != 'True'" />
</ItemGroup>
<Import Project="..\ElectronNET\build\ElectronNET.targets" Condition="$(ElectronNetDevMode)" />
</Project>

View File

@@ -0,0 +1,50 @@
using ElectronNET.API;
namespace ElectronNET.WebApp
{
using System;
using System.Threading.Tasks;
using ElectronNET.API.Entities;
public class Program
{
public static async Task Main(string[] args)
{
var runtimeController = ElectronNetRuntime.RuntimeController;
try
{
await runtimeController.Start();
await runtimeController.WaitReadyTask;
await ElectronBootstrap();
await runtimeController.WaitStoppedTask;
}
catch (Exception ex)
{
Console.WriteLine(ex);
await runtimeController.Stop().ConfigureAwait(false);
await runtimeController.WaitStoppedTask.WaitAsync(TimeSpan.FromSeconds(2)).ConfigureAwait(false);
}
}
public static async Task ElectronBootstrap()
{
//AddDevelopmentTests();
var browserWindow = await Electron.WindowManager.CreateWindowAsync(new BrowserWindowOptions
{
Width = 1152,
Height = 940,
Show = false,
}, "https://github.com/ElectronNET/Electron.NET");
await browserWindow.WebContents.Session.ClearCacheAsync();
browserWindow.OnReadyToShow += () => browserWindow.Show();
}
}
}

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- https://go.microsoft.com/fwlink/?LinkID=208121. -->
<Project>
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>publish\Release\net8.0\linux-x64</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<_TargetId>Folder</_TargetId>
<TargetFramework>net8.0</TargetFramework>
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
<SelfContained>false</SelfContained>
<PublishSingleFile>false</PublishSingleFile>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<DeleteExistingFiles>true</DeleteExistingFiles>
<ExcludeApp_Data>false</ExcludeApp_Data>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<PublishProvider>FileSystem</PublishProvider>
<PublishUrl>publish\Release\net8.0\win-x64\</PublishUrl>
<WebPublishMethod>FileSystem</WebPublishMethod>
<_TargetId>Folder</_TargetId>
<TargetFramework>net8.0</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- https://go.microsoft.com/fwlink/?LinkID=208121. -->
<Project>
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>publish\Release\net8.0\win-x64</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<_TargetId>Folder</_TargetId>
<TargetFramework>net8.0</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>false</SelfContained>
<PublishSingleFile>false</PublishSingleFile>
<PublishReadyToRun>false</PublishReadyToRun>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,31 @@
{
"$schema": "https://raw.githubusercontent.com/electron-userland/electron-builder/refs/heads/master/packages/app-builder-lib/scheme.json",
"compression": "maximum",
//"afterPack": "bin/Assets/afterPack.js",
//"beforePack": "bin/Assets/beforePack.js",
"buildNumber": "",
"linux": {
"target": [
"tar.xz"
//"AppImage",
//"rpm",
//"deb",
//"pacman"
],
"executableArgs": [ "--no-sandbox" ],
"icon": "bin/Assets/icon.png",
"artifactName": "${name}-${arch}-${version}.${ext}"
},
"win": {
"target": [
{
"target": "portable",
"arch": "x64"
}
],
"icon": "bin/Assets/icon.ico"
},
"mac": {
"icon": "bin/Assets/icon.icns"
}
}

View File

@@ -0,0 +1,30 @@
{
"profiles": {
"DotNet (unpackaged)": {
"commandName": "Project",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Electron (unpackaged)": {
"commandName": "Executable",
"executablePath": "node",
"commandLineArgs": "node_modules/electron/cli.js main.js -unpackedelectron",
"workingDirectory": "$(TargetDir).electron",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"WSL": {
"commandName": "WSL2",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_URLS": "http://localhost:8001/"
},
"distributionName": ""
},
"Profile 1": {
"commandName": "Project"
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 KiB