agracio/edge-js

Dotnet executable path in standalone mode

weliwita opened this issue · 9 comments

I can see following logic in the creclrembedding.cpp line 337.

if (mode == host_mode_t::standalone && dotnetExecutablePath.empty())
	{
		throwV8Exception("This 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 don't understand why it looks for dotnet executable binary in the PATH if this is standalone mode. I think it should not be dependent on any external 'dotnet' binary but only the binaries in the EDGE_APP_ROOT. Can someone please explain the correct way to run in standalone mode?

What problem you trying to solve? What kind of errors you getting when running your app and what settings you pass to it?
Edit: What OS and .NET runtime you using?

Hi agracio,

Thank you for all the effort you are putting to keep this project live. We really appreciate it.

This issue is electron specific, I have done few modifications to run this app on electron. I know there is a separate edge-js project for electron, but I think it only changes the way it is built(against node vs electron) So if we build correctly this project should also run on electron. As we don't have dotnet core on client machines where electron app is installed, we package the standalone app with electron
OS is windows(but reproducible on Mac). latest dotnet sdk version is 2.1.4
I have a repro app here .https://github.com/weliwita/edge-js-quick-start

  1. Creating the standalone core app.
cd src\QuickStart.Core
publish.bat

published app will be created in \src\QuickStart.Core\bin\Release\netcoreapp2.0\win-x64\publish

  1. Install dependencies
    npm install

fixing to build with electron

In node-modules\edge-js\package.json remove the install script

"scripts": {
    "test": "node tools/test.js"
  },

Build the dependencies with electron builder

node_modules\.bin\electron-builder install-app-deps
  1. Run the app
    npm run start

you will get the expected output as you have dotnet on your path

.NET Core welcomes Node.Js
  1. Now set the path just to include nodejs, removing dotnet from the path.

set PATH="C:\Program Files\nodejs"

it will throw following exception

App threw an error during load
Error: This 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.
    at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:172:20)
    at Object.Module._extensions..node (module.js:598:18)
    at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:172:20)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Module.require (module.js:513:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (D:\r\Repo\edge-js-quick-start\node_modules\edge-js\lib\edge.js:53:8)
    at Object.<anonymous> (D:\r\Repo\edge-js-quick-start\node_modules\edge-js\lib\edge.js:181:3)
Terminate batch job (Y/N)? Y
  1. If we comment out the exception throwing section and build the edge-js, app works as expected
    host_mode_t mode = coreclr_exists_in_dir(edgeAppDir) ? host_mode_t::standalone : host_mode_t::muxer;

	// if (mode == host_mode_t::standalone && dotnetExecutablePath.empty())
	// {
	// 	throwV8Exception("This 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.");
	// }

	pal::string_t configFile, devConfigFile, sdkPath;

node_modules\.bin\electron-builder install-app-deps

This is also reproducible on mac-os following similar steps.

electron version is 1.8.2

I think the problem is with if statement itself, currently is throws exception when app is standalone and there is no .NET SDK., instead it should should throw exception when app is not standalone and there is no .NET SDK

if (mode == host_mode_t:: muxer && dotnetExecutablePath.empty())
{
    throwV8Exception("This 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.");
}

Yes, That makes sense. Thanks.

Will be done in a couple of days, it will also be merged to electron-edge-js so you dont need to recompile the project

Thanks, Will it be not required to compile for Mac and Linux? Last time I checked It was just windows binaries are included and had to compile for Mac and Linux.

Mac and Linux compile on npm install

Just published new versions of edge-js and electron-edge-js with fix, let me know if you still have problems.

Ok, it solved the issue. Thank You