Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when building Electron app for dist #21

Closed
stephen776 opened this issue Jun 12, 2018 · 33 comments
Closed

Error when building Electron app for dist #21

stephen776 opened this issue Jun 12, 2018 · 33 comments

Comments

@stephen776
Copy link

When I package my electron app for distribution using electron-builder I am getting the following error:

Error: his is not a published, standalone application and we are unable to locate the .NET Core SDK.  Please make sure that it is installed; see http://microsoft.com/net/core for more details.

I am using the same .NET code as the quickstart for a proof-of-concept.

Any ideas on why I'd get this error? I have confirmed the .dlls are getting copied into the package.

@agracio
Copy link
Owner

agracio commented Jun 12, 2018

To be honest its not the first time that people have problems when using electron-builder. Since I never used it myself I cannot offer much assistance.
Have you confirmed that process.env.EDGE_APP_ROOT is set to location that all your dlls are located, that location should also include a complete set of .NET Core dlls list like it does in quick start.

@stephen776
Copy link
Author

stephen776 commented Jun 12, 2018

I have just confirmed that the EDGE_APP_ROOT is being set properly. I have configured electron-builder to not use .asar files to package the app. I can see that the package does contain all of the .dlls in the proper place but the issue remains.

Electron-builder is an extremely popular package in the electron community. Would it be possible for you to look into the issue and possibly help support it's usage. Do you know of other users that have successfully got this combo to work?

@agracio
Copy link
Owner

agracio commented Jun 12, 2018

From what I have seen so far Edge.js does not work from asar archives in general. There were multiple issues and questions on Slack about it and to my knowledge you cannot pack Edge.js into asar archive. You would need to have all Edge.js specific parts outside asar archive.

@agracio
Copy link
Owner

agracio commented Jun 12, 2018

On a related note if you create a sample repo that uses electron-builder to package the app I will try to take a look at it, but really don't hold your breath.

@consense
Copy link

Hmmm, had various problems with the build step of native dependency edge.js with electron-builder in the past, but those were minor bumps.
In general edge.js works from asar electron app also in dist

@agracio
Copy link
Owner

agracio commented Jun 12, 2018

First time I hear about it, all the issues that were raised so far were left unresolved. But this means there is some hope :) Are you getting this problem on specific OS or all of them?

@stephen776
Copy link
Author

@consense How are you packaging you .net code in your electron-builder app? Are you referencing DLLs or scripting .net right inside your JS code?

My setup on the edge/.net side is exactly like the electron-edge-js quickstart. I have tried including the DLLs as extraFiles and extraResources.
the files end up where they should be but no luck running the packaged app.

@stephen776
Copy link
Author

I am on a mac, btw.

@agracio
Copy link
Owner

agracio commented Jun 12, 2018

@stephen776 I am assuming that quickstart does not work for you at all? This is a separate issue not related to electron-builder

@stephen776
Copy link
Author

Quickstart works fine as is. When I take the same .net code from the quickstart and copy it into my electron-builder app...it works fine in development but when I package for release, I get the error.

@agracio
Copy link
Owner

agracio commented Jun 12, 2018

Ok, this is rather confusing as I am getting multiple reports of edge-js-quick-start not working on macOS and Linux. Will have to look into all of the issues separately.
As I said electron-builder repo that replicates the problem (preferably on Windows) would be greatly appreciated.

@stephen776
Copy link
Author

I had two issues when getting the quickstart to run on mac:

  1. need to make sure the path to the assembly is correct. The path syntax that works on windows didn't work on mac.

  2. Had to ensure I was using the right version of npm using nvm(8.9.3) when installing building npm packages.

Other than that works fine on mac.

@agracio
Copy link
Owner

agracio commented Jun 13, 2018

Can you output the following env variables to console: process.env.EDGE_APP_ROOT and process.env.EDGE_BOOTSTRAP_DIR and see where they pointing? The error indicates that Edge cannot find .NET Core dlls in the directory.
And as I mentioned before I would only be able to investigate it myself if there is a repo that reproduces the problem.

@consense
Copy link

@stephen776 I am referencing dlls which are included via extraResources electron-builder config
Just to avoid a misunderstanding here: I am not using .net core, but expecting a normal dotnet runtime installed on the client.

@agracio
Copy link
Owner

agracio commented Jun 13, 2018

The error is specific to .NET Core, quick-start is compiled to .NET Core and specifies process.env.EDGE_USE_CORECLR = 1. If your binaries are compiled to .NET Framework and you not setting the env variable you should not get this error.

@consense
Copy link

Ok - in that case sorry for having been misleading.
Was just replying to to give a different experience in regards to

From what I have seen so far Edge.js does not work from asar archives in general.

which didnt mention .NET Core.

@agracio
Copy link
Owner

agracio commented Jun 13, 2018

No problem.

@stephen776
Copy link
Author

stephen776 commented Jun 13, 2018

@agracio if I explicitly set process.env.EDGE_APP_ROOT and log both

process.env.EDGE_APP_ROOT
process.env.EDGE_BOOTSTRAP_DIR

to console, then EDGE_BOOTSTRAP_DIR is undefined and EDGE_APP_ROOT is set properly.

Here is a link to a repo to reproduce. I notice that the error message is different on windows vs mac but same basic problem building and running from either platform.

https://github.com/stephen776/electron-edge-package-test

this is the electron-react template I am using on my main project. if you head to /app/components/home.tsx you will see where I am calling the .net dll. The dotnet code copied directly from quickstart lives in /app/dotnet

this project uses the 2 package.json setup. You will need to run npm install from the root and then again from /app directory. electron-edge-js lives in that second package.json

I use nvm on mac to specify my node version as 8.9.3.

Project runs fine in dev mode: run npm run dev to start. You will see result logged to console.

Error occurs when project is packaged with electron builder: run npm run package to create the bundle. files will end up in /release Run the app to see the error in console.

Thanks for taking the time to check this out.

@agracio
Copy link
Owner

agracio commented Jun 13, 2018

Give me a couple of days, just finishing some improvements to .NET Core handling including support for .NET Standard.

@agracio
Copy link
Owner

agracio commented Jun 13, 2018

Just tested it on Windows and followed instructions you provided.
After I run npm run package and then run the installer from release folder it installs the app into %USER%\AppData\Local\Programs\electron-react-typescript-boilerplate.
When I run the app from that location process.env.EDGE_APP_ROOT points to %USER%\AppData\Local\Programs\electron-react-typescript-boilerplate\app\dotnet\QuickStart.Core\bin\Debug\netcoreapp2.0 that does not exist after install so Edge.js fails.

@stephen776
Copy link
Author

Thank you for digging that up. I will try to track down exactly why the files aren't ending up where they should.

@stephen776
Copy link
Author

@agracio Ok, I have made some progress on this but I am still stuck. If you pull the lastest master branch of my sample posted earlier and follow the same testing instructions, you will notice that it works fine in dev mode and packaged on windows. But the package does not work on mac.

I have confirmed that the path is now correct on all platforms with the updated code but the error remains on mac when packaged for release: Error: This is not a published, standalone application and we are unable to locate the .NET Core SDK

@agracio
Copy link
Owner

agracio commented Jun 19, 2018

Can you update you electron-edge-js to version 8.3.6, it has some specific fixes for .NET Core especially on macOS and Linux.
Make sure that all .NET Core dlls are copied to the specified path, same as when running quick-start.
Edit: make sure you rebuild .NET solution after updating electron-edge-js package.
I will try your project on macOS myself when i have time.

@stephen776
Copy link
Author

Just upgraded to 8.3.6. Same issue. EDGE_BOOTSTRAP_DIR remains undefined with my configuration but EDGE_APP_ROOT is pointing to the correct place.

I am noticing that bootstrap.dll that lives in the node_modules folder under electron-edge-js/lib/bootstrap/bin/Release/netcoreapp1.1 is not getting copied into my distribution's package. Could this be causing the issue?

@agracio
Copy link
Owner

agracio commented Jun 19, 2018

No, it is not suppose to be copied. The error indicates that .NET Core dlls are not found in that location.

@stephen776
Copy link
Author

my package has nothing in that folder besides bootstrap.deps.json

@agracio
Copy link
Owner

agracio commented Jun 19, 2018

I mean in EDGE_APP_ROOT folder

@stephen776
Copy link
Author

image

Here are the entire contents of the folder that EDGE_APP_ROOT points to. Anything seem to be missing?

@agracio
Copy link
Owner

agracio commented Jun 19, 2018

Should be the same content as when you run using npm run dev command.

@stephen776
Copy link
Author

Ok, that's what I expected. I just confirmed. The files are exactly the same in dev and the package.

I am kind of lost at this point. Have tried everything I can think of.

@agracio
Copy link
Owner

agracio commented Jun 19, 2018

There is another possibility that once app is published it no longer has access to .NET Core files on the machine. In that case you would need to create a real standalone package and bundle it with the app.
Take a look at this related issue: agracio/edge-js#24.
What do you have in your publish folder, have you tried pointing EDGE_APP_ROOT to it?

For some info on publishing a standalone app take a look at this post: https://stackoverflow.com/questions/46829860/how-to-distribute-a-net-core-2-0-console-application-on-osx.

Or you can try to manually copy all .NET Core files into the directory.

@stephen776
Copy link
Author

Ok, I think you've got me on the right path now. Referring back to the docs on the main edge.js repo, there are instructions to configure a dotnet core app to run standalone. Combining those settings with your linked SO post got me to a packaged build that runs. Just a few more kinks to iron out but it's looking good.

Thank you for all of the support.

@nboon
Copy link

nboon commented Aug 23, 2018

In case anyone else is running into problems publishing a self contained app:
We found that, although the dotnet publish command reference says that the --self-contained flag defaults to true if you specify a Runtime Identifier this only appears to be the case when the project OutputType is set to exe. If you want to publish a self contained library you have to explicitly add the --self-contained flag as well as the --runtime option to include the framework assemblies and most importantly the apphost.exe when publishing.

e.g. dotnet publish MyLibrary.csproj -r win10-x64 --self-contained

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants