From 6b0205467b2fda9454dfa34aa6021f229eff2501 Mon Sep 17 00:00:00 2001 From: Daniel Gidman Date: Thu, 9 Dec 2021 13:11:24 -0600 Subject: [PATCH 1/5] Support for .NET 6 Also included is the ability to target a specific project in the `electronize build/start` command using /dotnet-project --- ElectronNET.API/ElectronNET.API.csproj | 17 ++++---- ElectronNET.API/runtimeconfig.json | 7 ++++ ElectronNET.CLI/Commands/BuildCommand.cs | 10 ++++- .../Commands/StartElectronCommand.cs | 9 +++- ElectronNET.CLI/ElectronNET.CLI.csproj | 2 +- ....csproj => ElectronNET.WebApp.NET5.csproj} | 2 +- .../ElectronNET.WebApp.NET6.csproj | 42 +++++++++++++++++++ ElectronNET.sln | 8 +++- README.md | 2 +- buildAll.cmd | 22 +++++----- buildAll.sh | 38 +++++++++++------ start.cmd | 4 +- start.sh | 4 +- 13 files changed, 127 insertions(+), 40 deletions(-) mode change 100644 => 100755 ElectronNET.API/ElectronNET.API.csproj create mode 100755 ElectronNET.API/runtimeconfig.json mode change 100644 => 100755 ElectronNET.CLI/Commands/BuildCommand.cs mode change 100644 => 100755 ElectronNET.CLI/ElectronNET.CLI.csproj rename ElectronNET.WebApp/{ElectronNET.WebApp.csproj => ElectronNET.WebApp.NET5.csproj} (96%) mode change 100644 => 100755 create mode 100755 ElectronNET.WebApp/ElectronNET.WebApp.NET6.csproj mode change 100644 => 100755 buildAll.sh diff --git a/ElectronNET.API/ElectronNET.API.csproj b/ElectronNET.API/ElectronNET.API.csproj old mode 100644 new mode 100755 index 7e948cff..fed07722 --- a/ElectronNET.API/ElectronNET.API.csproj +++ b/ElectronNET.API/ElectronNET.API.csproj @@ -1,7 +1,6 @@  - net5.0 true ..\artifacts ElectronNET.API @@ -10,8 +9,10 @@ Electron.NET MIT https://github.com/ElectronNET/Electron.NET/ - Building cross platform electron based desktop apps with .NET Core and ASP.NET Core. -This package contains the API to access the "native" electron API. + + Building cross platform electron based desktop apps with .NET Core and ASP.NET Core. + This package contains the API to access the "native" electron API. + https://github.com/ElectronNET/Electron.NET/ git true @@ -20,6 +21,7 @@ This package contains the API to access the "native" electron API. PackageIcon.png 99.0.0.0 true + net5.0;net6.0 @@ -33,15 +35,16 @@ This package contains the API to access the "native" electron API. - - + + - + all runtime; build; native; contentfiles; analyzers - + + diff --git a/ElectronNET.API/runtimeconfig.json b/ElectronNET.API/runtimeconfig.json new file mode 100755 index 00000000..0439511e --- /dev/null +++ b/ElectronNET.API/runtimeconfig.json @@ -0,0 +1,7 @@ +{ + "runtimeOptions": { + "configProperties": { + "System.Drawing.EnableUnixSupport": true + } + } +} \ No newline at end of file diff --git a/ElectronNET.CLI/Commands/BuildCommand.cs b/ElectronNET.CLI/Commands/BuildCommand.cs old mode 100644 new mode 100755 index d9c07465..55200bac --- a/ElectronNET.CLI/Commands/BuildCommand.cs +++ b/ElectronNET.CLI/Commands/BuildCommand.cs @@ -14,6 +14,7 @@ public class BuildCommand : ICommand 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;win\"'" + Environment.NewLine + + "Optional: '/dotnet-project' with the desired project file to build" + 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 + @@ -35,6 +36,7 @@ public BuildCommand(string[] args) } private string _paramTarget = "target"; + private string _paramDotNetProject = "dotnet-project"; private string _paramDotNetConfig = "dotnet-configuration"; private string _paramElectronArch = "electron-arch"; private string _paramElectronParams = "electron-params"; @@ -106,8 +108,14 @@ public Task ExecuteAsync() var dotNetPublishFlags = GetDotNetPublishFlags(parser); + var project = string.Empty; + if (parser.Arguments.ContainsKey(_paramDotNetProject)) + { + project = parser.Arguments[_paramDotNetProject][0]; + } + var command = - $"dotnet publish -r {platformInfo.NetCorePublishRid} -c \"{configuration}\" --output \"{tempBinPath}\" {string.Join(' ', dotNetPublishFlags.Select(kvp => $"{kvp.Key}={kvp.Value}"))} --self-contained"; + $"dotnet publish {project} -r {platformInfo.NetCorePublishRid} -c \"{configuration}\" --output \"{tempBinPath}\" {string.Join(' ', dotNetPublishFlags.Select(kvp => $"{kvp.Key}={kvp.Value}"))} --self-contained"; // output the command Console.ForegroundColor = ConsoleColor.Green; diff --git a/ElectronNET.CLI/Commands/StartElectronCommand.cs b/ElectronNET.CLI/Commands/StartElectronCommand.cs index 03382ecd..06cf801a 100644 --- a/ElectronNET.CLI/Commands/StartElectronCommand.cs +++ b/ElectronNET.CLI/Commands/StartElectronCommand.cs @@ -23,6 +23,7 @@ public StartElectronCommand(string[] args) } private string _aspCoreProjectPath = "project-path"; + private string _paramDotNetProject = "dotnet-project"; private string _arguments = "args"; private string _manifest = "manifest"; private string _clearCache = "clear-cache"; @@ -105,9 +106,15 @@ public Task ExecuteAsync() configuration = parser.Arguments[_paramDotNetConfig][0]; } + var project = string.Empty; + if (parser.Arguments.ContainsKey(_paramDotNetProject)) + { + project = parser.Arguments[_paramDotNetProject][0]; + } + if (parser != null && !parser.Arguments.ContainsKey("watch")) { - resultCode = ProcessHelper.CmdExecute($"dotnet publish -r {platformInfo.NetCorePublishRid} -c \"{configuration}\" --output \"{tempBinPath}\" {publishReadyToRun} {publishSingleFile} --no-self-contained", aspCoreProjectPath); + resultCode = ProcessHelper.CmdExecute($"dotnet publish {project} -r {platformInfo.NetCorePublishRid} -c \"{configuration}\" --output \"{tempBinPath}\" {publishReadyToRun} {publishSingleFile} --no-self-contained", aspCoreProjectPath); } if (resultCode != 0) diff --git a/ElectronNET.CLI/ElectronNET.CLI.csproj b/ElectronNET.CLI/ElectronNET.CLI.csproj old mode 100644 new mode 100755 index a4bd0118..03a3a3de --- a/ElectronNET.CLI/ElectronNET.CLI.csproj +++ b/ElectronNET.CLI/ElectronNET.CLI.csproj @@ -77,7 +77,7 @@ - + all runtime; build; native; contentfiles; analyzers diff --git a/ElectronNET.WebApp/ElectronNET.WebApp.csproj b/ElectronNET.WebApp/ElectronNET.WebApp.NET5.csproj old mode 100644 new mode 100755 similarity index 96% rename from ElectronNET.WebApp/ElectronNET.WebApp.csproj rename to ElectronNET.WebApp/ElectronNET.WebApp.NET5.csproj index 4b7e2319..73a490f3 --- a/ElectronNET.WebApp/ElectronNET.WebApp.csproj +++ b/ElectronNET.WebApp/ElectronNET.WebApp.NET5.csproj @@ -19,7 +19,7 @@ - + diff --git a/ElectronNET.WebApp/ElectronNET.WebApp.NET6.csproj b/ElectronNET.WebApp/ElectronNET.WebApp.NET6.csproj new file mode 100755 index 00000000..d2039112 --- /dev/null +++ b/ElectronNET.WebApp/ElectronNET.WebApp.NET6.csproj @@ -0,0 +1,42 @@ + + + net6.0 + OutOfProcess + AspNetCoreModule + win-x64 + 4.2 + + + + + + + + + + + + + + + + + + + PreserveNewest + + + PreserveNewest + + + + + Never + + + + + PreserveNewest + + + \ No newline at end of file diff --git a/ElectronNET.sln b/ElectronNET.sln index eb37b676..a878657f 100644 --- a/ElectronNET.sln +++ b/ElectronNET.sln @@ -3,7 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.27130.2027 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ElectronNET.WebApp", "ElectronNET.WebApp\ElectronNET.WebApp.csproj", "{7C048379-401C-4345-B5E7-BE232DEA8157}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ElectronNET.WebApp.NET5", "ElectronNET.WebApp\ElectronNET.WebApp.NET5.csproj", "{7C048379-401C-4345-B5E7-BE232DEA8157}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ElectronNET.WebApp.NET6", "\\Mac\Home\Repos\Electron.NET\ElectronNET.WebApp\ElectronNET.WebApp.NET6.csproj", "{76F72AED-31F4-4289-AFB5-D7ECA84072B8}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ElectronNET.API", "ElectronNET.API\ElectronNET.API.csproj", "{A78157BA-B754-45F1-969F-D6A513CA0E72}" EndProject @@ -63,6 +65,10 @@ Global {B33E9B82-B6B4-4DB0-B6EE-61CC34641518}.Debug|Any CPU.Build.0 = Debug|Any CPU {B33E9B82-B6B4-4DB0-B6EE-61CC34641518}.Release|Any CPU.ActiveCfg = Debug|Any CPU {B33E9B82-B6B4-4DB0-B6EE-61CC34641518}.Release|Any CPU.Build.0 = Debug|Any CPU + {76F72AED-31F4-4289-AFB5-D7ECA84072B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {76F72AED-31F4-4289-AFB5-D7ECA84072B8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {76F72AED-31F4-4289-AFB5-D7ECA84072B8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {76F72AED-31F4-4289-AFB5-D7ECA84072B8}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/README.md b/README.md index e6e1533a..72d1648d 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Well... there are lots of different approaches how to get a X-plat desktop app r ## 🛠 Requirements to run: -The current Electron.NET CLI builds Windows/macOS/Linux binaries. Our API uses .NET 5, so our minimum base OS is the same as [.NET 5](https://github.com/dotnet/core/blob/master/release-notes/5.0/5.0-supported-os.md). +The current Electron.NET CLI builds Windows/macOS/Linux binaries. Our API multi-targets .NET 5 & .NET6, so our minimum base OS is the same as [.NET 5](https://github.com/dotnet/core/blob/master/release-notes/5.0/5.0-supported-os.md) or [.NET 6](https://github.com/dotnet/core/blob/main/release-notes/6.0/supported-os.md). Also you should have installed: diff --git a/buildAll.cmd b/buildAll.cmd index 31f75f7b..3d276f03 100755 --- a/buildAll.cmd +++ b/buildAll.cmd @@ -5,32 +5,34 @@ cd ElectronNet.API dotnet restore dotnet build cd .. + echo "Restore & Build CLI" cd ElectronNet.CLI dotnet restore dotnet build -cd .. -echo "Restore & Build WebApp Demo" -cd ElectronNet.WebApp -dotnet restore -dotnet build - -echo "Invoke electronize build in WebApp Demo" echo "Install CLI" dotnet tool uninstall ElectronNET.CLI -g dotnet tool install ElectronNET.CLI -g +cd .. + +echo "Restore & Build WebApp Demo" +cd ElectronNet.WebApp +dotnet restore ElectronNet.WebApp.NET5.csproj +dotnet build ElectronNet.WebApp.NET5.csproj + +echo "Invoke electronize build in WebApp Demo" echo "/target xxx (dev-build)" -electronize build /target custom win7-x86;win /dotnet-configuration Debug /electron-arch ia32 /electron-params "--publish never" +electronize build /target custom win7-x86;win /dotnet-project ElectronNet.WebApp.NET5.csproj /dotnet-configuration Debug /electron-arch ia32 /electron-params "--publish never" echo "/target win (dev-build)" -electronize build /target win /electron-params "--publish never" +electronize build /target win /dotnet-project ElectronNet.WebApp.NET5.csproj /electron-params "--publish never" echo "/target custom win7-x86;win (dev-build)" -electronize build /target custom win7-x86;win /electron-params "--publish never" +electronize build /target custom win7-x86;win /dotnet-project ElectronNet.WebApp.NET5.csproj /electron-params "--publish never" :: Be aware, that for non-electronnet-dev environments the correct :: invoke command would be dotnet electronize ... diff --git a/buildAll.sh b/buildAll.sh old mode 100644 new mode 100755 index b88f32ec..ee09d5f1 --- a/buildAll.sh +++ b/buildAll.sh @@ -1,17 +1,30 @@ # flag arguments to target specific builds are available. # sh ./buildAll.sh + # sh ./buildAll.sh -t osx # sh ./buildAll.sh -t win # sh ./buildAll.sh -t linux +# sh ./buildAll.sh -t osx -p *.NET5.csproj +# sh ./buildAll.sh -t win -p *.NET5.csproj +# sh ./buildAll.sh -t linux -p *.NET5.csproj + +# sh ./buildAll.sh -t osx -p *.NET6.csproj +# sh ./buildAll.sh -t win -p *.NET6.csproj +# sh ./buildAll.sh -t linux -p *.NET6.csproj + target=default -while getopts t: flag; do +project="*.NET5.cspoj" +while getopts t:p: flag; do case "${flag}" in t) target=${OPTARG} ;; + p) project=${OPTARG} ;; esac done +echo "Targeting $target & Project $project" + dir=$(cd -P -- "$(dirname -- "$0")" && pwd -P) echo "Start building Electron.NET dev stack..." @@ -31,38 +44,37 @@ echo "Restore & Build CLI" pushd $dir/ElectronNET.CLI dotnet restore dotnet build + + echo "Install CLI as dotnet tool" + dotnet tool uninstall ElectronNET.CLI -g + dotnet tool install ElectronNET.CLI -g popd echo "Restore & Build WebApp Demo" pushd $dir/ElectronNET.WebApp - dotnet restore - dotnet build - - echo "Install CLI as dotnet tool" - - dotnet tool uninstall ElectronNET.CLI -g - dotnet tool install ElectronNET.CLI -g + dotnet restore $project + dotnet build $project echo "Invoke electronize build in WebApp Demo" if [[ "$target" != "default" ]]; then echo "/target $target (dev-build)" - electronize build /target $target + electronize build /target $target /dotnet-project $project else echo "/target win (dev-build)" - electronize build /target win + electronize build /target win /dotnet-project $project echo "/target linux (dev-build)" - electronize build /target linux + electronize build /target linux /dotnet-project $project # Cannot publish osx/win on windows due to: # NETSDK1095: Optimizing assemblies for performance is not supported for the selected target platform or architecture. if [[ "$OSTYPE" != "linux-gnu"* ]]; then echo "/target osx (dev-build)" - electronize build /target osx + electronize build /target osx /dotnet-project $project echo "/target custom win7-x86;win (dev-build)" - electronize build /target custom "win7-x86;win" + electronize build /target custom "win7-x86;win" /dotnet-project $project fi fi popd diff --git a/start.cmd b/start.cmd index a898fde8..a84bbbb8 100644 --- a/start.cmd +++ b/start.cmd @@ -1,8 +1,8 @@ echo Bundle ASP.NET Core Project into EXE cd ElectronNET.WebApp -dotnet restore -dotnet publish -r win-x64 --output ../ElectronNET.Host/bin/ +dotnet restore *.NET5.csproj +dotnet publish *.NET5.csproj -r win-x64 --output ../ElectronNET.Host/bin/ echo Start Electron with bundled EXE cd ..\ElectronNET.Host diff --git a/start.sh b/start.sh index ac13c7e3..c74bac32 100755 --- a/start.sh +++ b/start.sh @@ -1,8 +1,8 @@ echo Bundle ASP.NET Core Project into EXE cd ElectronNET.WebApp -dotnet restore -dotnet publish -r osx-x64 --output ../ElectronNET.Host/bin/ +dotnet restore *.NET5.csproj +dotnet publish *.NET5.csproj -r osx-x64 --output ../ElectronNET.Host/bin/ echo Start Electron with bundled EXE cd ../ElectronNET.Host From 946fbd7a7234b286a0f3512d3e841cbe319253ee Mon Sep 17 00:00:00 2001 From: Daniel Gidman Date: Thu, 9 Dec 2021 13:51:13 -0600 Subject: [PATCH 2/5] Update appveyor image --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 62d46748..61e8c1f6 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,5 +1,5 @@ version: 1.0.{build} -image: Visual Studio 2019 +image: Visual Studio 2022 build_script: - cmd: buildAll.cmd pull_requests: From ffdf034f5f09f1c016687a6ed8bd59274df36c5b Mon Sep 17 00:00:00 2001 From: Daniel Gidman Date: Thu, 9 Dec 2021 14:01:55 -0600 Subject: [PATCH 3/5] appveyor dedicated build --- appveyor.cmd | 28 ++++++++++++++++++++++++++++ appveyor.yml | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100755 appveyor.cmd diff --git a/appveyor.cmd b/appveyor.cmd new file mode 100755 index 00000000..fe7cd6e9 --- /dev/null +++ b/appveyor.cmd @@ -0,0 +1,28 @@ +echo "Start building Electron.NET dev stack..." + +echo "Restore & Build API" +cd ElectronNet.API +dotnet restore +dotnet build +cd .. + +echo "Restore & Build CLI" +cd ElectronNet.CLI +dotnet restore +dotnet build + +echo "Install CLI" + +dotnet tool uninstall ElectronNET.CLI -g +dotnet tool install ElectronNET.CLI -g +cd .. + +echo "Restore & Build WebApp Demo" +cd ElectronNet.WebApp +dotnet restore ElectronNet.WebApp.NET5.csproj +dotnet build ElectronNet.WebApp.NET5.csproj + +echo "Invoke electronize build in WebApp Demo" + +echo "/target win (dev-build)" +electronize build /target win /dotnet-project ElectronNet.WebApp.NET5.csproj /electron-params "--publish never" \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml index 61e8c1f6..0770f4d0 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,7 +1,7 @@ version: 1.0.{build} image: Visual Studio 2022 build_script: -- cmd: buildAll.cmd +- cmd: appveyor.cmd pull_requests: do_not_increment_build_number: true artifacts: From 4b314940d738252761a3cce9fa47b6424481299a Mon Sep 17 00:00:00 2001 From: Daniel Gidman Date: Thu, 23 Dec 2021 10:54:44 -0600 Subject: [PATCH 4/5] Update ElectronNET.sln removing the full path reference as suggested. Co-authored-by: alborozd --- ElectronNET.sln | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ElectronNET.sln b/ElectronNET.sln index a878657f..71d12364 100644 --- a/ElectronNET.sln +++ b/ElectronNET.sln @@ -5,7 +5,7 @@ VisualStudioVersion = 15.0.27130.2027 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ElectronNET.WebApp.NET5", "ElectronNET.WebApp\ElectronNET.WebApp.NET5.csproj", "{7C048379-401C-4345-B5E7-BE232DEA8157}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ElectronNET.WebApp.NET6", "\\Mac\Home\Repos\Electron.NET\ElectronNET.WebApp\ElectronNET.WebApp.NET6.csproj", "{76F72AED-31F4-4289-AFB5-D7ECA84072B8}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ElectronNET.WebApp.NET6", "ElectronNET.WebApp\ElectronNET.WebApp.NET6.csproj", "{76F72AED-31F4-4289-AFB5-D7ECA84072B8}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ElectronNET.API", "ElectronNET.API\ElectronNET.API.csproj", "{A78157BA-B754-45F1-969F-D6A513CA0E72}" EndProject From 2331ef43b4c2028c57564f3a8c885555c81661d4 Mon Sep 17 00:00:00 2001 From: Daniel Gidman Date: Tue, 25 Jan 2022 14:08:40 -0600 Subject: [PATCH 5/5] Support electronize as a dotnet 6 target tool --- ElectronNET.CLI/ElectronNET.CLI.csproj | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ElectronNET.CLI/ElectronNET.CLI.csproj b/ElectronNET.CLI/ElectronNET.CLI.csproj index 03a3a3de..ae398502 100755 --- a/ElectronNET.CLI/ElectronNET.CLI.csproj +++ b/ElectronNET.CLI/ElectronNET.CLI.csproj @@ -2,8 +2,6 @@ Exe - - net5.0 dotnet-electronize electronize @@ -30,6 +28,7 @@ PackageIcon.png true + net5.0;net6.0