diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index af155b1..1abdc7b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -145,8 +145,6 @@ jobs: needs: build strategy: matrix: - # electron: [29.4.6, 30.5.1, 31.6.0] - # electron: [29.4.6] os: [windows-2022] # fail-fast: false diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cd9ad6c..c1b82da 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -28,6 +28,8 @@ on: - '.circleci' - '.circleci/*' - 'README.md' + - '*.sln' + - '*.vcxproj' push: branches-ignore: - 'circleci' @@ -57,6 +59,8 @@ on: - '.circleci' - '.circleci/*' - 'README.md' + - '*.sln' + - '*.vcxproj' env: ACTIONS_ALLOW_UNSECURE_COMMANDS: true # required to setup CSC diff --git a/.gitignore b/.gitignore index 56bd3d4..1c06c54 100644 --- a/.gitignore +++ b/.gitignore @@ -93,3 +93,6 @@ test/mochawesome-report mochawesome-report mochawesome.json +release +*.zip + diff --git a/.npmignore b/.npmignore index 8a8c19a..2bcafbb 100644 --- a/.npmignore +++ b/.npmignore @@ -104,4 +104,7 @@ test/mochawesome-report mochawesome-report mochawesome.json *.zip -*.sln \ No newline at end of file +*.sln +xunit*.* +getVersion*.js +*.vcxproj \ No newline at end of file diff --git a/lib/native/win32/ia32/29.0.0/edge_coreclr.node b/lib/native/win32/ia32/29.0.0/edge_coreclr.node index 796ef67..ffa5b88 100644 Binary files a/lib/native/win32/ia32/29.0.0/edge_coreclr.node and b/lib/native/win32/ia32/29.0.0/edge_coreclr.node differ diff --git a/lib/native/win32/ia32/29.0.0/edge_nativeclr.node b/lib/native/win32/ia32/29.0.0/edge_nativeclr.node index c7947e3..dd7154f 100644 Binary files a/lib/native/win32/ia32/29.0.0/edge_nativeclr.node and b/lib/native/win32/ia32/29.0.0/edge_nativeclr.node differ diff --git a/lib/native/win32/x64/29.0.0/edge_coreclr.node b/lib/native/win32/x64/29.0.0/edge_coreclr.node index d8933c5..0903078 100644 Binary files a/lib/native/win32/x64/29.0.0/edge_coreclr.node and b/lib/native/win32/x64/29.0.0/edge_coreclr.node differ diff --git a/lib/native/win32/x64/29.0.0/edge_nativeclr.node b/lib/native/win32/x64/29.0.0/edge_nativeclr.node index 459793c..ab816a5 100644 Binary files a/lib/native/win32/x64/29.0.0/edge_nativeclr.node and b/lib/native/win32/x64/29.0.0/edge_nativeclr.node differ diff --git a/lib/native/win32/x64/30.0.0/edge_coreclr.node b/lib/native/win32/x64/30.0.0/edge_coreclr.node index 1904bed..634eea7 100644 Binary files a/lib/native/win32/x64/30.0.0/edge_coreclr.node and b/lib/native/win32/x64/30.0.0/edge_coreclr.node differ diff --git a/lib/native/win32/x64/30.0.0/edge_nativeclr.node b/lib/native/win32/x64/30.0.0/edge_nativeclr.node index c57ce4d..7a449b7 100644 Binary files a/lib/native/win32/x64/30.0.0/edge_nativeclr.node and b/lib/native/win32/x64/30.0.0/edge_nativeclr.node differ diff --git a/lib/native/win32/x64/31.0.0/edge_coreclr.node b/lib/native/win32/x64/31.0.0/edge_coreclr.node index 0cc0077..20be27b 100644 Binary files a/lib/native/win32/x64/31.0.0/edge_coreclr.node and b/lib/native/win32/x64/31.0.0/edge_coreclr.node differ diff --git a/lib/native/win32/x64/31.0.0/edge_nativeclr.node b/lib/native/win32/x64/31.0.0/edge_nativeclr.node index a798454..3f69077 100644 Binary files a/lib/native/win32/x64/31.0.0/edge_nativeclr.node and b/lib/native/win32/x64/31.0.0/edge_nativeclr.node differ diff --git a/lib/native/win32/x64/32.0.0/edge_coreclr.node b/lib/native/win32/x64/32.0.0/edge_coreclr.node index 4e70785..08e249b 100644 Binary files a/lib/native/win32/x64/32.0.0/edge_coreclr.node and b/lib/native/win32/x64/32.0.0/edge_coreclr.node differ diff --git a/lib/native/win32/x64/32.0.0/edge_nativeclr.node b/lib/native/win32/x64/32.0.0/edge_nativeclr.node index 0db4701..506156a 100644 Binary files a/lib/native/win32/x64/32.0.0/edge_nativeclr.node and b/lib/native/win32/x64/32.0.0/edge_nativeclr.node differ diff --git a/lib/native/win32/x64/33.0.0/edge_coreclr.node b/lib/native/win32/x64/33.0.0/edge_coreclr.node index d05494e..2aa154b 100644 Binary files a/lib/native/win32/x64/33.0.0/edge_coreclr.node and b/lib/native/win32/x64/33.0.0/edge_coreclr.node differ diff --git a/lib/native/win32/x64/33.0.0/edge_nativeclr.node b/lib/native/win32/x64/33.0.0/edge_nativeclr.node index ab07f8c..8e047c3 100644 Binary files a/lib/native/win32/x64/33.0.0/edge_nativeclr.node and b/lib/native/win32/x64/33.0.0/edge_nativeclr.node differ diff --git a/package-lock.json b/package-lock.json index faf7be6..ebb7794 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,21 +1,21 @@ { "name": "electron-edge-js", - "version": "33.0.0", + "version": "33.0.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "electron-edge-js", - "version": "33.0.0", + "version": "33.0.1", "hasInstallScript": true, "license": "MIT", "dependencies": { "edge-cs": "npm:@agracio/edge-cs@^1.3.7", - "follow-redirects": "^1.15.9", "nan": "^2.22.0" }, "devDependencies": { - "electron": "^32.0.0", + "electron": "^33.0.0", + "follow-redirects": "^1.15.9", "mocha": "10.7.3", "mochawesome": "^7.1.3", "mochawesome-merge": "^4.3.0", @@ -522,9 +522,9 @@ } }, "node_modules/electron": { - "version": "32.1.2", - "resolved": "https://registry.npmjs.org/electron/-/electron-32.1.2.tgz", - "integrity": "sha512-CXe6doFzhmh1U7daOvUzmF6Cj8hssdYWMeEPRnRO6rB9/bbwMlWctcQ7P8NJXhLQ88/vYUJQrJvlJPh8qM0BRQ==", + "version": "33.0.2", + "resolved": "https://registry.npmjs.org/electron/-/electron-33.0.2.tgz", + "integrity": "sha512-C2WksfP0COsMHbYXSJG68j6S3TjuGDrw/YT42B526yXalIlNQZ2GeAYKryg6AEMkIp3p8TUfDRD0+HyiyCt/nw==", "dev": true, "hasInstallScript": true, "license": "MIT", @@ -691,6 +691,7 @@ "version": "1.15.9", "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz", "integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==", + "dev": true, "funding": [ { "type": "individual", @@ -2634,9 +2635,9 @@ "integrity": "sha512-sFwGCGmoa9JdODegeDFJL4IH6N8IgDobxbS31BiXaiOdf8bC7EyHigFp0WYRKhIgK72E9nLnNwiRJRMO/AYGdg==" }, "electron": { - "version": "32.1.2", - "resolved": "https://registry.npmjs.org/electron/-/electron-32.1.2.tgz", - "integrity": "sha512-CXe6doFzhmh1U7daOvUzmF6Cj8hssdYWMeEPRnRO6rB9/bbwMlWctcQ7P8NJXhLQ88/vYUJQrJvlJPh8qM0BRQ==", + "version": "33.0.2", + "resolved": "https://registry.npmjs.org/electron/-/electron-33.0.2.tgz", + "integrity": "sha512-C2WksfP0COsMHbYXSJG68j6S3TjuGDrw/YT42B526yXalIlNQZ2GeAYKryg6AEMkIp3p8TUfDRD0+HyiyCt/nw==", "dev": true, "requires": { "@electron/get": "^2.0.0", @@ -2756,7 +2757,8 @@ "follow-redirects": { "version": "1.15.9", "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz", - "integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==" + "integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==", + "dev": true }, "fs-extra": { "version": "8.1.0", diff --git a/package.json b/package.json index 295fbe3..78b2fb9 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "url": "http://tomasz.janczuk.org", "twitter": "tjanczuk" }, - "version": "33.0.0", + "version": "33.0.1", "description": "Edge.js: run .NET and Node.js in-process on Electron", "tags": [ "owin", @@ -42,11 +42,11 @@ "license": "MIT", "dependencies": { "edge-cs": "npm:@agracio/edge-cs@^1.3.7", - "follow-redirects": "^1.15.9", "nan": "^2.22.0" }, "devDependencies": { - "electron": "^32.0.0", + "electron": "^33.0.0", + "follow-redirects": "^1.15.9", "mocha": "10.7.3", "mochawesome": "^7.1.3", "mochawesome-merge": "^4.3.0", diff --git a/src/CoreCLREmbedding/coreclrembedding.cpp b/src/CoreCLREmbedding/coreclrembedding.cpp index 52ebce4..7d0553d 100644 --- a/src/CoreCLREmbedding/coreclrembedding.cpp +++ b/src/CoreCLREmbedding/coreclrembedding.cpp @@ -52,7 +52,7 @@ InitializeFunction initialize; "EdgeJs",\ "CoreCLREmbedding",\ functionName,\ - (void**) functionPointer);\ + (void**) (functionPointer));\ pal::clr_palstring(functionName, &functionNameString);\ \ if (FAILED(result))\ @@ -209,7 +209,7 @@ HRESULT CoreClrEmbedding::Initialize(BOOL debugMode) pal::string_t edgeDebug; pal::getenv(_X("EDGE_DEBUG"), &edgeDebug); - if (edgeDebug.length() > 0) + if (!edgeDebug.empty()) { trace::enable(); } @@ -265,9 +265,9 @@ HRESULT CoreClrEmbedding::Initialize(BOOL debugMode) pal::string_t edgeBootstrapDir; pal::getenv(_X("EDGE_BOOTSTRAP_DIR"), &edgeBootstrapDir); - if (edgeAppDir.length() == 0) + if (edgeAppDir.empty()) { - if (edgeBootstrapDir.length() != 0) + if (!edgeBootstrapDir.empty()) { trace::info(_X("CoreClrEmbedding::Initialize - No EDGE_APP_ROOT environment variable present, using the Edge bootstrapper directory at %s"), edgeBootstrapDir.c_str()); edgeAppDir = edgeBootstrapDir; @@ -321,7 +321,7 @@ HRESULT CoreClrEmbedding::Initialize(BOOL debugMode) size_t previousIndex = 0; size_t currentIndex = pathEnvironmentVariable.find(PATH_SEPARATOR); - while (dotnetExecutablePath.length() == 0 && previousIndex != std::string::npos) + while (dotnetExecutablePath.empty() && previousIndex != std::string::npos) { if (currentIndex != std::string::npos) { @@ -371,16 +371,43 @@ HRESULT CoreClrEmbedding::Initialize(BOOL debugMode) if (mode != host_mode_t::standalone) { trace::verbose(_X("CoreClrEmbedding::Initialize - host mode: muxer")); + + std::vector appConfigFiles; + pal::readdir(edgeAppDir, _X("*.runtimeconfig.json"), &appConfigFiles); + pal::string_t runtimeconfigfile; + pal::string_t sdkDirectory; fx_muxer_t::resolve_sdk_dotnet_path(dotnetDirectory, &sdkDirectory); - pal::string_t dotnetAssemblyPath(sdkDirectory); - append_path(&dotnetAssemblyPath, _X("dotnet.dll")); + if (!sdkDirectory.empty()) // Default case: SDK is installed and found - using dotnet.runtimeconfig.json from SDK folder + { + runtimeconfigfile = pal::string_t(sdkDirectory); + append_path(&runtimeconfigfile, _X("dotnet.dll")); + get_runtime_config_paths_from_app(runtimeconfigfile, &configFile, &devConfigFile); + } + else if (appConfigFiles.size() == 1) // Fallback: No SDK directory found (probably only .NET runtime installed), trying to use [appname].runtimeconfig.json instead + { + runtimeconfigfile = pal::string_t(edgeAppDir); + append_path(&runtimeconfigfile, appConfigFiles[0].c_str()); - get_runtime_config_paths_from_app(dotnetAssemblyPath, &configFile, &devConfigFile); - } + trace::info(_X("CoreClrEmbedding::Initialize - No SDK directory found - Exactly one (%s) app runtimeconfig file found in the Edge app directory, using that"), runtimeconfigfile.c_str()); + configFile = pal::string_t(runtimeconfigfile); + } + else if (appConfigFiles.size() > 1) // Throw error: No SDK found but more than one runtimeconfig.json found in app folder - Which one is correct? + { + std::vector edgeAppDirCstr; + pal::pal_clrstring(edgeAppDir, &edgeAppDirCstr); + throwV8Exception("CoreClrEmbedding::Initialize - Multiple app runtimeconfig files (*.runtimeconfig.json) files exist in the Edge.js application directory (%s).", edgeAppDirCstr.data()); + return E_FAIL; + } + else // No app runtimeconfigfile found and also no SDK found + { + throwV8Exception("CoreClrEmbedding::Initialize - Could not find any runtimeconfig file ([appname].runtimeconfig.json in app folder nor dotnet.runtimeconfig.json in sdk folder)"); + return E_FAIL; + } + } else { trace::verbose(_X("CoreClrEmbedding::Initialize - host mode: standalone")); @@ -392,12 +419,12 @@ HRESULT CoreClrEmbedding::Initialize(BOOL debugMode) pal::string_t packagesEnvironmentVariable; pal::getenv(_X("NUGET_PACKAGES"), &packagesEnvironmentVariable); - if (packagesEnvironmentVariable.length() == 0) + if (packagesEnvironmentVariable.empty()) { pal::string_t profileDirectory; pal::getenv(_X("USERPROFILE"), &profileDirectory); - if (profileDirectory.length() == 0) + if (profileDirectory.empty()) { pal::getenv(_X("HOME"), &profileDirectory); } @@ -638,14 +665,14 @@ HRESULT CoreClrEmbedding::Initialize(BOOL debugMode) SetCallV8FunctionDelegateFunction setCallV8Function; - CREATE_DELEGATE("GetFunc", &getFunc); - CREATE_DELEGATE("CallFunc", &callFunc); - CREATE_DELEGATE("ContinueTask", &continueTask); - CREATE_DELEGATE("FreeHandle", &freeHandle); - CREATE_DELEGATE("FreeMarshalData", &freeMarshalData); - CREATE_DELEGATE("SetCallV8FunctionDelegate", &setCallV8Function); - CREATE_DELEGATE("CompileFunc", &compileFunc); - CREATE_DELEGATE("Initialize", &initialize); + CREATE_DELEGATE("GetFunc", &getFunc) + CREATE_DELEGATE("CallFunc", &callFunc) + CREATE_DELEGATE("ContinueTask", &continueTask) + CREATE_DELEGATE("FreeHandle", &freeHandle) + CREATE_DELEGATE("FreeMarshalData", &freeMarshalData) + CREATE_DELEGATE("SetCallV8FunctionDelegate", &setCallV8Function) + CREATE_DELEGATE("CompileFunc", &compileFunc) + CREATE_DELEGATE("Initialize", &initialize) trace::info(_X("CoreClrEmbedding::Initialize - Getting runtime info")); diff --git a/src/CoreCLREmbedding/host/runtime_config.cpp b/src/CoreCLREmbedding/host/runtime_config.cpp index 0b3f36e..39254f5 100644 --- a/src/CoreCLREmbedding/host/runtime_config.cpp +++ b/src/CoreCLREmbedding/host/runtime_config.cpp @@ -19,6 +19,7 @@ runtime_config_t::runtime_config_t(const pal::string_t& path, const pal::string_ trace::verbose(_X("Runtime config [%s] is valid=[%d]"), path.c_str(), m_valid); } +// Parse runtimeconfig, see documentation here https://github.com/dotnet/sdk/blob/main/documentation/specs/runtime-configuration-file.md bool runtime_config_t::parse_opts(const json_value& opts) { // Note: both runtime_config and dev_runtime_config call into the function. @@ -38,7 +39,7 @@ bool runtime_config_t::parse_opts(const json_value& opts) { m_properties[property.first] = property.second.is_string() ? property.second.as_string() - : property.second.to_string(); + : property.second.serialize(); } } @@ -71,17 +72,43 @@ bool runtime_config_t::parse_opts(const json_value& opts) m_prerelease_roll_fwd = prerelease_roll_fwd->second.as_bool(); } - auto framework = opts_obj.find(_X("framework")); - if (framework == opts_obj.end()) + auto framework = opts_obj.find(_X("framework")); + const web::json::object* fx_obj = nullptr; + + if (framework == opts_obj.end()) // Found no "framework" section in file, trying "frameworks" or "includedFrameworks" { - return true; + auto frameworks = opts_obj.find(_X("frameworks")); + if (frameworks == opts_obj.end()) + { + frameworks = opts_obj.find(_X("includedFrameworks")); + + if (frameworks == opts_obj.end()) + { + trace::verbose(_X("Found neither 'framework' nor 'frameworks' nor 'includedFrameworks' section in runtimeconfig.json file")); + return true; + } + } + + const auto& frameworks_array = frameworks->second.as_array(); + if (frameworks_array.size() == 0) + { + trace::verbose(_X("'Frameworks' in runtimeconfig.json file section found but is empty")); + return true; + } + + fx_obj = &frameworks_array.at(0).as_object(); // Using first element of frameworks array + } + else + { + fx_obj = &framework->second.as_object(); } m_portable = true; + m_fx_name = fx_obj->at(_X("name")).as_string(); + m_fx_ver = fx_obj->at(_X("version")).as_string(); + + trace::verbose(_X("Found framework [%s] with version [%s] in runtimeconfig.json file"), m_fx_name.c_str(), m_fx_ver.c_str()); - const auto& fx_obj = framework->second.as_object(); - m_fx_name = fx_obj.at(_X("name")).as_string(); - m_fx_ver = fx_obj.at(_X("version")).as_string(); return true; } diff --git a/tools/build.bat b/tools/build.bat index 5ed74c2..909a085 100644 --- a/tools/build.bat +++ b/tools/build.bat @@ -5,6 +5,7 @@ if "%1" equ "" ( echo e.g. build.bat release "30.0.0" exit /b -1 ) +rmdir /S /Q ..\build\ FOR /F "tokens=* USEBACKQ" %%F IN (`node -p process.arch`) DO (SET ARCH=%%F) SET FLAVOR=%1