The browser loads the DLL file before waking up Electron - dll

my electron app depends on C++ dll files. I was able to wake Electron App up in the browser, but the file it depends on is not loaded, I got win32 error 126. If I choose to open Electron directly by double-clicking instead of opening it from the browser, the files it depends on will load in.Everything is all right.
What's the difference between using a browser to wake up an Electron app and double-clicking to open an Electron app ?
electron-builder Version: 20.19.2
Electron Version: 2.0.18
my code:
package.json
"build": {
"extraResources": [
{
"from": "./a.dll",
"to": "../"
},
{
"from": "./c.pem",
"to": "../"
},
{
"from": "./b.dll",
"to": "../"
}
],
"nsis": {
"oneClick": false,
"allowToChangeInstallationDirectory": true,
"createDesktopShortcut": true,
"createStartMenuShortcut": true,
"include": "script/urlProtocol.nsh"
}
}
urlProtocol.nsh
!macro customInstall
DetailPrint "Register voice URI Handler"
DeleteRegKey HKCR "voice"
WriteRegStr HKCR "voice" "" "URL:voice"
WriteRegStr HKCR "voice" "URL Protocol" ""
WriteRegStr HKCR "voice\shell" "" ""
WriteRegStr HKCR "voice\shell\Open" "" ""
WriteRegStr HKCR "voice\shell\Open\command" "" "$INSTDIR\${APP_EXECUTABLE_FILENAME} %1"
!macroend
a.dll、b.dll、c.pem are in the root directory of the project

Error 126 is ERROR_MOD_NOT_FOUND.
You probably rely on relative paths somewhere. You don't control the current directory when your application is started so no modules should be loaded from paths starting with ./ nor ../.
You should also quote your registered verb command correctly:
WriteRegStr HKCR "voice\shell\Open\command" "" '"$INSTDIR\${APP_EXECUTABLE_FILENAME}“ “%1"'

Related

Vue.js+Electron app has breakpoints unbound and doesn't stop on it in VS Code

I configured a Vue.js project with Electron using Electron Builder and I can1t debug it.
If I run my electron:serve script (which calls vue-cli-service electron:serve) in "Run and Debug" of VS it runs my app correctly, but sets the breakpoints of my main file (background.js), and any other, as unbound, as you can see in the image bellow:
I tried also to set launch.json with a "node.js electron main" config. But when I run debugger with this config it doesn't find the electron app at main.js, probably because main.js is a vue app.
{
"version": "0.2.0",
"configurations": [
{
"name": "Electron Main",
"program": "${workspaceFolder}/main.js",
"request": "launch",
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron",
"skipFiles": [
"<node_internals>/**"
],
"type": "node"
},
And if I exchange the main.js in this config to background.js it also doesn't find.
I set breakpoint at background.js line 13. And in main.js also.
I tried this config of launch.json also. Note that in cwd I have the path to my src folder, where I have the electron file, background.js, and stills it says that it did not find. I tried without the / after src also:
Here's my repository.

VSCode Debug and Jest: No breakpoints running with npm, CWD error running with node

I am trying to get breakpoints to hit in Jest Debug for VS Code.
This launch config runs but does not hit breakpoints:
{
"type": "node",
"request": "launch",
"name": "Test",
"runtimeExecutable": "npm",
"runtimeArgs": ["test"],
"port": 9229
}
This launch config does not run, but it looks like it hits breakpoints.
It opens fs.js at a debugger breakpoint with this error:
Error: ENOENT: no such file or directory, access 'node_modules/jest-cli/bin/package.json'
Like it's looking for the workspace's package.json file inside the jest bin directory.
{
"type": "node",
"request": "launch",
"name": "Jest All",
"program": "${workspaceFolder}/node_modules/.bin/jest",
"args": ["--runInBand"],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}
For me the solution was that inside VSCodes Debugging Panel inside the Breakpoints section, I had All Exceptions checked. Unchecking this allowed the debugger to work as I expected.
Also the issue did not happen when checking the Uncaught Exceptions Breakpoint handler. All Exceptions actually catches all not just inside your but also inside others code, regardless if they are handled or not.
I had a package.json file one directory up. I deleted it, but still got the same error. I fixed it by copying it to a new directory further up on my path, I believe so VS Code could detect it was a new workspace.

How can I get the Amazon Cognito Identity SDK working in Aurelia?

I am trying to get the Amazon Cognito Identity SDK working in Aurelia. I do not have a lot of Javascript experience and am very unfamiliar with the various dependency systems.
I installed the Cognito SDK using: npm install --save amazon-cognito-identity-js
I then edited my aurelia_project/aurelia.json file as suggested in the Aurelia documentation to include a new client library dependency in build.bundles vendor-bundle dependencies:
"sjcl",
"jsbn",
{
"name": "aws-sdk",
"path": "../node_modules/aws-sdk/",
"main": "dist/aws-sdk"
},
{
"name": "amazon-cognito-identity-js",
"path": "../node_modules/amazon-cognito-identity-js/dist",
"main": "amazon-cognito-identity.min"
}
However, when I try to run the code using au run I get the error: Error: ENOENT: no such file or directory, open '/Users/nathanskone/Projects/scc/aurelia-app/src/xmlbuilder.js'
I have tried to include xmlbuilder in my aurelia.json to no avail. When it is included I end up getting this error about lodash: Error: ENOENT: no such file or directory, open '/Users/nathanskone/Projects/scc/aurelia-app/src/lodash/object/assign.js'
I haven't found any way to get past the lodash error.
Is there anyone out there familiar with the Aurelia dependency system that could help?
Thanks,
Nathan
EDIT #2: While I got past the xmlbuilder/lodash errors, I have run into further errors trying to bundle the aws-sdk. Here is my current aurelia.json:
"dependencies": [
{
"name": "xmlbuilder",
"path": "../node_modules/xmlbuilder/lib",
"main": "index"
},
{
"name": "aws-sdk",
"path": "../node_modules/aws-sdk",
"main": "index",
"resources": ["lib/region_config.json"]
},
And the error I am currently getting:
Error: ENOENT: no such file or directory, open '/Users/nathanskone/Projects/scc/aurelia-app/src/crypto.js'
If I remove the resources (lib/region_config.json) then I get this error instead:
Error: ENOENT: no such file or directory, open '/Users/nathanskone/Projects/scc/aurelia-app/node_modules/aws-sdk/lib/region_config.json.js'
I think crypto is actually an object defined in aws-sdk/lib/util.js, which is required by aws-sdk/lib/region_config.js.
Try the compiled library instead, using the compiled lib bundled just fine.
Also the library seems to define window.AWS, so injecting it or not will work
{
"name": "aws-sdk",
"path": "../node_modules/aws-sdk/dist",
"main": "aws-sdk.min",
"exports": "AWS"
}
UPDATE:
It seems the only way to import those libraries is by using the prepend section, the libraries write to the window variable so it can still be accesible to your app scripts, only by not importing them like ES6 modules.
"prepend": [
"node_modules/aws-sdk/dist/aws-sdk.min.js",
"node_modules/amazon-cognito-identity-js/dist/aws-cognito-sdk.min.js",
"node_modules/amazon-cognito-identity-js/dist/amazon-cognito-identity.min.js",
"node_modules/bluebird/js/browser/bluebird.core.js",
"scripts/require.js"
],

Exclude non-minified files from publish in `project.json` with ASP.NET Core

I am trying to find a proper configuration for the publishOptions inside project.json (ASP.NET Core 1.0 / Full Framework) so that non-minified files are not published.
Official documetation doesn't help much: project.json reference.
Searching for globbing patterns, and finding some artilcles with gulp examples, I came up with this wwwroot/js/**/*!(*.min.js), but it doesn't seem to work.
Is my syntax wrong? Or, it's just that project.json and dotnet publish don't support this syntax?
"publishOptions": {
"include": [
"wwwroot",
"Views",
"Areas/**/Views",
"appsettings.json",
"web.config"
],
"exclude": [
"wwwroot/lib",
"wwwroot/js/**/*!(*.min.js)",
"wwwroot/css/*.less",
"wwwroot/_references.js"
],
"includeFiles": [],
"excludeFiles": []
},
The typical workflow for JavaScript files/libraries management is to use gulp or grunt tasks to copy over the necessary files into the wwwroot folder which may happen on certain events (prebuild, postbuild, project open, clean).
In the latest tooling, the default MVC doesn't include gulpfile.js anymore as the most common usage was to minify and bundle js files, even when no external libraries were used so gulp may be a bit overwhelming for new users.
But it can easily be brought back, when you right-click the bundleconfig.json file in the solution explorer and choose "Bundler & Minifier" > "Convert to Gulp".
This creates a gulpfile.js and package.json (nodejs dependencies) in the root of your project and adds npm folder to the "Dependencies" section of Solution Explorer. When you watch in the Windows Explorer, you'll see a node_modules folder in the project root folder. That's where npm will download all packages and it's dependencies.
The generated gulpfile.js looks like this and has a few predefined tasks. i won't use this file as example, as it is strongly based on the bundleconfig.json and it's structure and use my gulpfile.json which used to be shipped with older templates.
"use strict";
var gulp = require("gulp"),
rimraf = require("rimraf"),
concat = require("gulp-concat"),
cssmin = require("gulp-cssmin"),
uglify = require("gulp-uglify");
var webroot = "./wwwroot/";
var paths = {
app: webroot + "app/",
libs: webroot + "lib/",
js: webroot + "js/**/*.js",
minJs: webroot + "js/**/*.min.js",
css: webroot + "css/**/*.css",
minCss: webroot + "css/**/*.min.css",
concatJsDest: webroot + "js/app.min.js",
concatCssDest: webroot + "css/app.min.css"
};
gulp.task("clean:js", function (cb) {
rimraf(paths.concatJsDest, cb);
});
gulp.task("clean:libs", function (cb) {
rimraf(paths.libs, cb);
});
gulp.task("clean:css", function (cb) {
rimraf(paths.concatCssDest, cb);
});
gulp.task("clean", ["clean:js", "clean:css", "clean:libs"]);
gulp.task("min:js", function () {
return gulp.src([paths.js, "!" + paths.minJs], { base: "." })
.pipe(concat(paths.concatJsDest))
.pipe(uglify())
.pipe(gulp.dest("."));
});
gulp.task("min:css", function () {
return gulp.src([paths.css, "!" + paths.minCss])
.pipe(concat(paths.concatCssDest))
.pipe(cssmin())
.pipe(gulp.dest("."));
});
gulp.task("min", ["min:js", "min:css"]);
gulp.task("libs", function (cb) {
gulp.src([
'bootstrap/**/*.js',
'bootstrap/**/*.css',
'jquery/**/*.js`, // we can also limit this to `jquery/dist/**/*.js to only include distribution files
'jquery/**/*.css'
], {
cwd: "node_modules/**"
})
.pipe(gulp.dest(paths.libs));
});
gulp.task("app", function (cb) {
gulp.src([
'app/**.js'
])
.pipe(gulp.dest(paths.app));
});
gulp.task("default", ['clean', 'libs']);
It looks more complicated than it actually is. There are several minizier tasks (min:js, min:css) and one general minifier task min which just runs all others in sequence.
A clean task which deletes the output file(s) from wwwroot. When converting from the template, it deletes only the default wwwroot/js/site.min.js file.
Since there are no javascript libraries used in the default template, except of what's inside the wwwroot/lib folder already the packages are not handled that way.
So first thing you may want is to grab bootstrap and jquery from npm rather than the static versions provided by the template. So we add the dependencies to the package.json.
{
"name": "app",
"version": "0.0.0",
"private": true,
"dependencies": {
"bootstrap": "3.3.6",
"jquery": "2.2.0"
},
"devDependencies": {
"gulp": "3.8.11",
"gulp-concat": "2.5.2",
"gulp-cssmin": "0.1.7",
"gulp-uglify": "1.2.0",
"rimraf": "2.2.8"
}
}
The libs task from the gulpfile.js above for example will copy over all required files of a package to wwwroot. I said required, because in the packages there are often unbundled files for debugging and stuff, which we usually don't want inside wwwroot (they can grow quite big).
gulp.task("libs", function (cb) {
gulp.src([
'bootstrap/**/*.js',
'bootstrap/**/*.css'
], {
cwd: "node_modules/**"
})
.pipe(gulp.dest(paths.libs));
});
It will look for all *.js and *.css files within the bootstrap folder in node_modules folder and copy them over to path.libs which is configured as wwwroot/lib/.
The app task does the same for our own code. clean clears the folders and (i.e. before switching from debug to release build or before publishing).
Finally you can bind the tasks to certain VS Events. You need to open the "Task Runner Explorer" View (View > Other Window > Task Runner Explorer). There you can choose a task and right-click it, then "Binding" and choose one of the binding (Before Build, After Build, Clean, Projct Open). They are pretty self explaining, "Clean" means when you do "Build > Clean Solution".
Now to the publishing part. You can run certain command, when you publish your application (either via dotnet or Visual Studio).
In the project.json there is a scripts section for this.
"scripts": {
"prepublish": [ "npm install", "bower install", "gulp clean", "gulp min", "gulp libs" ],
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}
Each of the entries "prepublish" is one command to be executed. In this example, before the publishing begins, npm install will be executed first in order to restore all npm dependencies. Then bower install to install the dependencies managed by bower (remove it if you don't use bower and do all via npm).
The next three commands are the interesting ones, they will execute gulp tasks. We can also simplify this by adding a "publish" task.
gulp.task("publish", ['clean', 'libs', 'min']);
"scripts": {
"prepublish": [ "npm install", "bower install", "gulp publish" ],
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}
This will copy all the necessary files for publishment into the wwwroot folder, publish the files and then call the "postpublish" scripts.
That's a rough introduction in gulp. It's has a learning curve, but once you get it working it imrpoves the overall workflow.
What's not covered here is to add a watch task which may look into a certain folder (I usually use app folder in the project root) and when any file changes there run the app task, so the our code gets minifed and copied over to wwwroot and is available when we debug it.
A simple alternative is:
Rename unminified source to *.debug.js and *.debug.css
They are now easier to exclude:
"publishOptions": {
"include": [
"wwwroot"
],
"exclude": [
"wwwroot/**/*.debug.*"
]
}
IMHO unminified source should stick out and look abnormal. It is more deserving of a file name wart than minified code.
This also brings the build output files into line with the rest of the .Net build configuration. It makes it clear that your debug versions may well include extra logging and debug utilities and that its not for production.

Cocoapods - Code object is not signed at all

I'm trying to build an OS X target that imports the Dropbox framework and am getting this error:
CodeSign /Users/jessebunch/Library/Developer/Xcode/DerivedData/TestApp-bxjgcsgqofvdyidodqalwworvmat/Build/Products/Debug/TestApp.app
cd /Users/jessebunch/Projects/testapp/Example
export CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
Signing Identity: "-"
/usr/bin/codesign --force --sign 80B12837F588266A4A1FB1EF7D9C7F58E3A91E67 /Users/jessebunch/Library/Developer/Xcode/DerivedData/TestApp-bxjgcsgqofvdyidodqalwworvmat/Build/Products/Debug/TestApp.app
/Users/jessebunch/Library/Developer/Xcode/DerivedData/TestApp-bxjgcsgqofvdyidodqalwworvmat/Build/Products/Debug/TestApp.app: code object is not signed at all
In subcomponent: /Users/jessebunch/Library/Developer/Xcode/DerivedData/TestApp-bxjgcsgqofvdyidodqalwworvmat/Build/Products/Debug/TestApp.app/Contents/Frameworks/Dropbox.framework
Command /usr/bin/codesign failed with exit code 1
Here is the podspec I've created for this:
{
"name": "Dropbox-OSX",
"version": "3.1.1",
"summary": "The Dropbox Sync & Datastore API SDK for OSX.",
"homepage": "https://www.dropbox.com/developers/sync",
"license": {
"type": "Copyright",
"file": "dropbox-osx-sync-sdk-3.1.1/LICENSE.txt"
},
"authors": "Dropbox",
"source": {
"http": "https://www.dropbox.com/developers/downloads/sdks/datastore/osx/dropbox-osx-sync-sdk-3.1.1.zip"
},
"platforms": {
"osx": null
},
"public_header_files": "dropbox-osx-sync-sdk-3.1.1/Dropbox.framework/Headers/*.h",
"preserve_paths": "dropbox-osx-sync-sdk-3.1.1/Dropbox.framework",
"frameworks": ["Dropbox"],
"vendored_frameworks": "dropbox-osx-sync-sdk-3.1.1/Dropbox.framework",
"resources": "dropbox-osx-sync-sdk-3.1.1/Dropbox.framework",
"xcconfig": {
"FRAMEWORK_SEARCH_PATHS": "\"${PODS_ROOT}/Dropbox-OSX/dropbox-osx-sync-sdk-3.1.1\""
},
"libraries": "c++",
"requires_arc": false
}
And I'm including it in my project like so:
target 'TestApp_Mac', :exclusive => true do
platform :osx, '10.10'
pod 'Dropbox-OSX', :podspec => './Specs/Dropbox-OSX.podspec.json', :inhibit_warnings => true
end
Any ideas how to fix this? I need Xcode to code sign the framework after copying it to the app bundle.
Here is what I've tried:
I added --deep to the codesigning flags. This gets me past this issue; however, then we get into the problem of "unsealed contents present in the root directory of an embedded framework" and I'm told that this is not a good idea anyway (see http://furbo.org/2013/10/17/code-signing-and-mavericks/)
Thanks!