Closed ronish-potiah-cko closed 6 years ago
Do you get the same error when you try to invoke the electron-packager directly (e.g. open a command prompt and execute this command)?
@robertmuehsig , when I run the electron-packager directly to execute the above command, I got:
Error: Cannot find module electron from 'C:\' at C:[path]\npm\node_modules\electron-packager\node_modules\resolve\lib\async.js ....... at FSReqWrap.oncomplete (fs.js:152:21) code: 'MODULE_NOT_FOUND'
Strange. Maybe it would help if you clean your node_modules folder and reinstall the electron stuff.
Hi @robertmuehsig , I've cleanup everything, re-install again but having the same issue. Can you try packaging it on your end?
Thanks.
Hi @ronish-potiah-cko, which CLI version is installed?
Use this command please:
dotnet electronize version
@robertmuehsig I had to move my core development to straight Electron, so I haven't had a chance to check. That said, I spent quite a bit of time deconstructing the architecture of Electron.NET over the past couple months and am convinced the dotnetelectronize CLI app is a huge anti-pattern that just needs to be killed. It's an example of the classic "build systems are too complicated, I'll just whip up a quick C# app that execs the stuff I need and that'll be better." And then it's not enough, so there's a v.next that does more, and does it better. But it's still not enough. And then it gets more complicated. And another hack gets added onto it. Electron apps and modern front-end development live in a world of npm and webpack. Npm and webpack each have >100x more dev-years invested in them than all of Electron.NET. They aren't complicated. And they are proven to scale and solve the real world complexity problems a build system really does need to solve. dotnetelectronize has already reached a level of complexity where it's consuming real architectural time and takes real time for other devs to understand and learn, and it's already lacking the next feature the next dev to try to adopt Electron.NET is going to need.
Your coding time is incredibly valuable. Please don't waste it on a totally non-scalable C# hack to "save us" from needing to understand npm and webpack. Throw away dotnetelectronize before it burns any more of your precious-to-us time and replace it with a couple entries in the scripts section of packages.json and a bit of webpack.config.js. You'll be much happier and we'll be much happier and the community will be able to do much more much faster. Npm and webpack simply aren't hard tech to learn and they are tech any dev doing modern frontend development simply has to understand. dotnetelectronize isn't a time saver or an effort saver or a cognitive saver. It's an anti-pattern.
@yoDon Thanks for your honest answer. Electron.NET is (at least currently) just a fancy idea/experiement with some good ideas and some mayor flaws. Sticking to the "pure" electron might be a pretty logical idea IMHO, because we can't competete with the manpower behind the other Electron related projects.
"Wasting" our time is a pretty hard description. At least we are learning quite a few things about OSS, Electron and .NET Core - so - everything is good for us :)
Maybe Electron.NET is a anti-pattern, but I know a bunch of people that actually hate Electron itself and they say the same thing about Electron. There are tons of other options (e.g. use the normal Electron, or Xamarin, or some magic cross compiler). Our goal is to write cross platform .NET applications and there are some ways to achive this. Use what works for you :)
@robertmuehsig thanks for hearing my comments in I think the way they were intended, with great respect for what you're doing and a deep desire for the project to succeed. This project is a super eye-opening way to think about Electron and I suspect the eventual v1.0 will look almost nothing like the first commit and yet I also think if we were able to take it back in a time machine to the time of that first commit we'd all look at the v1.0 and go "yes! that's exactly what we had in mind." It's just about figuring out how to get there.
Well - just TBH: We will see if we ever ship a proper v1.0, but thanks! 👍
@robertmuehsig , version is ElectronNET.CLI Version: 0.0.7.0
You will need the newer version 0.0.9 for the new syntax. You need to reference the new CLI in your .csproj like this:
<ItemGroup>
<DotNetCliToolReference Include="ElectronNET.CLI" Version="0.0.9" />
</ItemGroup>
And run "dotnet restore" - this should update your CLI version to the most recent one.
@robertmuehsig , I've changed the CLI version but with no luck.
Unhandled Exception: System.AggregateException: One or more errors occurred. (The given key was not present in the dictionary.) ---> System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
at System.ThrowHelper.ThrowKeyNotFoundException()
at System.Collections.Generic.Dictionary2.get_Item(TKey key) at ElectronNET.CLI.Commands.BuildCommand.<ExecuteAsync>b__13_0() at System.Threading.Tasks.Task
1.InnerInvoke()
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at ElectronNET.CLI.Program.Main(String[] args)
Could you try "dotnet electronize version" again?
ElectronNET.CLI Version: 0.0.9.0
I get the exact same error as ronosh-potiah-cko.
I am on osx and am running version 0.0.9.0
steps to reproduce:
git clone https://github.com/ElectronNET/electron.net-musicplayer-sample
cd electron.net-musicplayer-sample/MyElectronMusicPlayer
dotnet add package Microsoft.AspNetCore.Mvc
dotnet add package ElectronNET.API
dotnet restore
dotnet electronize init
If I then do
dotnet electronize start
then the app starts and everything is awesome
however if I try to build
dotnet electronize build osx
Then I get the same lovley stack trace
Build Electron Application...
Unhandled Exception: System.AggregateException: One or more errors occurred. (The given key was not present in the dictionary.) ---> System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
at System.ThrowHelper.ThrowKeyNotFoundException()
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at ElectronNET.CLI.Commands.BuildCommand.<ExecuteAsync>b__13_0()
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at ElectronNET.CLI.Program.Main(String[] args)
try this
dotnet electronize build /target win
$dotnet electronize build /target win
Build Electron Application...
Build ASP.NET Core App for win-x64...
Executing dotnet publish in this directory: /Users/jcr/Projects/dotnet/electron.net-musicplayer-sample/MyElectronMusicPlayer/obj/desktop/win
Build ASP.NET Core App for win-x64 under Release-Configuration...
Microsoft (R) Build Engine version 15.5.180.51428 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Restoring packages for /Users/jcr/Projects/dotnet/electron.net-musicplayer-sample/MyElectronMusicPlayer/MyElectronMusicPlayer.csproj...
Restore completed in 35.85 ms for /Users/jcr/Projects/dotnet/electron.net-musicplayer-sample/MyElectronMusicPlayer/MyElectronMusicPlayer.csproj.
Restore completed in 1.25 sec for /Users/jcr/Projects/dotnet/electron.net-musicplayer-sample/MyElectronMusicPlayer/MyElectronMusicPlayer.csproj.
MyElectronMusicPlayer -> /Users/jcr/Projects/dotnet/electron.net-musicplayer-sample/MyElectronMusicPlayer/bin/Release/netcoreapp2.0/win-x64/MyElectronMusicPlayer.dll
MyElectronMusicPlayer -> /Users/jcr/Projects/dotnet/electron.net-musicplayer-sample/MyElectronMusicPlayer/obj/desktop/win/bin/
node_modules missing in: /Users/jcr/Projects/dotnet/electron.net-musicplayer-sample/MyElectronMusicPlayer/obj/desktop/win/node_modules
Start npm install...
> uws@0.14.5 install /Users/jcr/Projects/dotnet/electron.net-musicplayer-sample/MyElectronMusicPlayer/obj/desktop/win/node_modules/uws
> node-gyp rebuild > build_log.txt 2>&1 || exit 0
> electron@1.7.11 postinstall /Users/jcr/Projects/dotnet/electron.net-musicplayer-sample/MyElectronMusicPlayer/obj/desktop/win/node_modules/electron
> node install.js
npm WARN ElectronNET.Host@1.0.0 No description
npm WARN ElectronNET.Host@1.0.0 No repository field.
added 192 packages in 19.222s
Start npm install electron-packager...
Electron Packager - make sure you invoke 'sudo npm install electron-packager --global' at /Users/jcr/Projects/dotnet/electron.net-musicplayer-sample/MyElectronMusicPlayer/obj/desktop/win manually. Sry.
Build Electron Desktop Application...
Executing electron magic in this directory: /Users/jcr/Projects/dotnet/electron.net-musicplayer-sample/MyElectronMusicPlayer/bin/desktop
Package Electron App for Platform win32...
bash: line 1: electron-packager: command not found
... done
so that sort of failed sort of worked
$ sudo npm install electron-packager --global
Password:
/usr/local/bin/electron-packager -> /usr/local/lib/node_modules/electron-packager/cli.js
+ electron-packager@11.2.0
added 229 packages in 13.386s
then try again:
$ dotnet electronize build /target win
Build Electron Application...
Build ASP.NET Core App for win-x64...
Executing dotnet publish in this directory: /Users/jcr/Projects/dotnet/electron.net-musicplayer-sample/MyElectronMusicPlayer/obj/desktop/win
Build ASP.NET Core App for win-x64 under Release-Configuration...
Microsoft (R) Build Engine version 15.5.180.51428 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Restore completed in 40.25 ms for /Users/jcr/Projects/dotnet/electron.net-musicplayer-sample/MyElectronMusicPlayer/MyElectronMusicPlayer.csproj.
Restoring packages for /Users/jcr/Projects/dotnet/electron.net-musicplayer-sample/MyElectronMusicPlayer/MyElectronMusicPlayer.csproj...
Restore completed in 1.03 sec for /Users/jcr/Projects/dotnet/electron.net-musicplayer-sample/MyElectronMusicPlayer/MyElectronMusicPlayer.csproj.
MyElectronMusicPlayer -> /Users/jcr/Projects/dotnet/electron.net-musicplayer-sample/MyElectronMusicPlayer/bin/Release/netcoreapp2.0/win-x64/MyElectronMusicPlayer.dll
MyElectronMusicPlayer -> /Users/jcr/Projects/dotnet/electron.net-musicplayer-sample/MyElectronMusicPlayer/obj/desktop/win/bin/
Skip npm install, because node_modules directory exists in: /Users/jcr/Projects/dotnet/electron.net-musicplayer-sample/MyElectronMusicPlayer/obj/desktop/win/node_modules
Build Electron Desktop Application...
Executing electron magic in this directory: /Users/jcr/Projects/dotnet/electron.net-musicplayer-sample/MyElectronMusicPlayer/bin/desktop
Package Electron App for Platform win32...
Downloading tmp-81862-0-electron-v1.7.11-win32-x64.zip
Downloading tmp-81862-1-SHASUMS256.txt-1.7.11
[============================================>] 100.0% of 2.96 kB (2.96 kB/s)
Wrote new app to /Users/jcr/Projects/dotnet/electron.net-musicplayer-sample/MyElectronMusicPlayer/bin/desktop/ElectronNET.Host-win32-x64
... done
That seemed to work, then I tried osx to make sure that will work too.
$ dotnet electronize build /target osx
Build Electron Application...
Build ASP.NET Core App for osx-x64...
Executing dotnet publish in this directory: /Users/jcr/Projects/dotnet/electron.net-musicplayer-sample/MyElectronMusicPlayer/obj/desktop/osx
Build ASP.NET Core App for osx-x64 under Release-Configuration...
Microsoft (R) Build Engine version 15.5.180.51428 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Restore completed in 42.07 ms for /Users/jcr/Projects/dotnet/electron.net-musicplayer-sample/MyElectronMusicPlayer/MyElectronMusicPlayer.csproj.
Restoring packages for /Users/jcr/Projects/dotnet/electron.net-musicplayer-sample/MyElectronMusicPlayer/MyElectronMusicPlayer.csproj...
Restore completed in 1.07 sec for /Users/jcr/Projects/dotnet/electron.net-musicplayer-sample/MyElectronMusicPlayer/MyElectronMusicPlayer.csproj.
MyElectronMusicPlayer -> /Users/jcr/Projects/dotnet/electron.net-musicplayer-sample/MyElectronMusicPlayer/bin/Release/netcoreapp2.0/osx-x64/MyElectronMusicPlayer.dll
MyElectronMusicPlayer -> /Users/jcr/Projects/dotnet/electron.net-musicplayer-sample/MyElectronMusicPlayer/obj/desktop/osx/bin/
Skip npm install, because node_modules directory exists in: /Users/jcr/Projects/dotnet/electron.net-musicplayer-sample/MyElectronMusicPlayer/obj/desktop/osx/node_modules
Build Electron Desktop Application...
Executing electron magic in this directory: /Users/jcr/Projects/dotnet/electron.net-musicplayer-sample/MyElectronMusicPlayer/bin/desktop
Package Electron App for Platform darwin...
Packaging app for platform darwin x64 using electron v1.7.11
Wrote new app to /Users/jcr/Projects/dotnet/electron.net-musicplayer-sample/MyElectronMusicPlayer/bin/desktop/ElectronNET.Host-darwin-x64
... done
and then actually ran the app
open /Users/jcr/Projects/dotnet/electron.net-musicplayer-sample/MyElectronMusicPlayer/bin/desktop/ElectronNET.Host-darwin-x64/ElectronNET.Host.app
Thanks for the suggestion :)
Hi, I guess the issue is with electron packager. When I try to package my application using command dotnet electronize build /target win , I encountered the followings:
electron-packager . --platform=win32 --arch=x64 --out="C:[app_path]\bin\desktop" --overwrite Packaging app for platform win32 x64 using electron v1.7.8 rcedit.exe failed with exit code 1. Fatal error: Unable to commit changes