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

A crossplatform way to create file associations #409

Closed
sunabozu opened this issue May 16, 2016 · 34 comments · May be fixed by qcif/data-curator#563 or Omrisnyk/trinity-wallet#88
Closed

A crossplatform way to create file associations #409

sunabozu opened this issue May 16, 2016 · 34 comments · May be fixed by qcif/data-curator#563 or Omrisnyk/trinity-wallet#88
Labels

Comments

@sunabozu
Copy link

There are the extend-info option and installer.nsi.tpl template that allow you to create file association on OS X and Windows separately, but from the application's perspective it's the same thing. Can we have a metadata field in package.json for describing file extensions we are interested in? It might look like this:

"build": {
  ...
  "file-associations": "txt|xyz|pdf"
}

Then it could be translated to specific entries in Info.plist and installer.nsi.tpl respectively. It would be very handy.

@develar
Copy link
Member

develar commented May 17, 2016

We don't use NSIS installer anymore.

And Squirrel.Windows is a pathetic parody (sorry, sorry, I am really sorry, but to be honest — it is true) to OS X app. Much better than NSIS and other windows installers, but still just a pathetic parody.

So, Squirrel.Windows doesn't support declarative way to create shortcuts or file associations. It is your responsibility in your app code to setup it during first run (or on update — events --squirrel-install or --squirrel-updated). First google result — https://www.npmjs.com/package/windows-registry (I didn't check, just google).

We are not commercial organization, so, I am not going to fix Squirrel.Windows in my free time. It is relatively easy to fix, though (we DO already our own fork to fix some obvious things, but I want to touch windows code only when it is really needed).

I see two ways to fix it:

  1. Magic app wrapper. i.e. you will be forced to use some framework. Don't like it.
  2. Info.json in the setup package. Before call --squirrel-install or --squirrel-updated handlers, we read descriptor and perform required actions. Yep — it is very easy to implement.

If you want to help — https://github.com/develar/Squirrel.Windows/tree/build (main branch is build). Sorry, I am not going to do it. No time. And no pleasure to touch dead *** windows.

@sunabozu
Copy link
Author

Thank you for a such detailed explanation. I'll try to handle it in the application itself.

@develar
Copy link
Member

develar commented Jul 11, 2016

Since NSIS outperforms Squirrel.Windows in all aspects, issue is reopened and will be implemented. For NSIS only. Because once #529 will be implemented, NSIS will be set as default windows target.

#563

@develar develar reopened this Jul 11, 2016
@develar
Copy link
Member

develar commented Jul 11, 2016

@sunabozu Your confirmation that file associations are the same for both platforms (example of your config) is very appreciated.

@develar develar removed the windows label Jul 18, 2016
develar added a commit to develar/electron-builder that referenced this issue Jul 18, 2016
@rwlnd
Copy link

rwlnd commented Aug 5, 2016

Following up on this, it would be nice if you could supply an image/icon for the file association in the build config.

@develar
Copy link
Member

develar commented Aug 5, 2016

@rwlnd mac or win?

@rwlnd
Copy link

rwlnd commented Aug 8, 2016

@develar - I'm sure it can be done on win , not sure about mac as I don't use that actively
The process to add an icon for a file association is descrbed in this stackoverflow

  • Right click the new key and create a subkey DefaultIcon.
  • Set the new key's default value to C:\Some\Path\To\Your\Icon\Ressource.ico,0 (the 0 is the index of the icon to be used; if there's only one icon in the ressource, it has to be 0).

@develar
Copy link
Member

develar commented Aug 8, 2016

Windows — we should use http://nsis.sourceforge.net/FileAssoc instead of current implementation to specify icon.

@develar
Copy link
Member

develar commented Aug 16, 2016

@rwlnd next version (5.28.0): just create ext.ico in the build directory (where ext is your ext). Or set icon (relative to build).

develar added a commit to develar/electron-builder that referenced this issue Aug 16, 2016
@sfraise
Copy link

sfraise commented Aug 18, 2016

Is this supposed to be working in the current build now?

I tried the following but didn't seem to work.
"build": {
"fileAssociations": {
"ext": "myext",
"name": "MYEXT"
}

@develar
Copy link
Member

develar commented Aug 18, 2016

@sfraise Yes. Please specify target OS and targets (nsis — boring or one-click, per-machine or not. Currently tested only for per-machine. Not per current user.

@sfraise
Copy link

sfraise commented Aug 18, 2016

@develar Thanks, I wasnt setting perMachine: true, all is golden now. Very very very awesome!

@sfraise
Copy link

sfraise commented Aug 26, 2016

This doesn't seem to work on Macs?

@develar
Copy link
Member

develar commented Aug 26, 2016

@sfraise Planned to implemented. Currently, I am very busy :) Cannot promise. Is it critical for you?

@sfraise
Copy link

sfraise commented Aug 26, 2016

It is kind of, app goes to client Monday. Primary device will be surface pro 3's so the windows installer is the most important but some will be using macs so has to be an option.

Is there anything I can do to help out?

@develar
Copy link
Member

develar commented Aug 26, 2016

Is there anything I can do to help out?

Well, you always can use extend-info (#397) Ok, I increase priority.

@sfraise
Copy link

sfraise commented Aug 26, 2016

If I have to I can try to manually add the association to the plist but your implementation is a heck of a lot more simple lol. Do you have a rough idea on when you'll have a chance to get to it?

@develar
Copy link
Member

develar commented Aug 26, 2016

Do you have a rough idea on when you'll have a chance to get to it?

2 days.

@sfraise
Copy link

sfraise commented Aug 26, 2016

Perfect, I really appreciate it.

@sfraise
Copy link

sfraise commented Aug 29, 2016

Hey Develar, we hand this app over to the client in about 7 hours so just wanted to see if you had a chance to do any more with the Mac implementation? I'm sure we'll be pushing out a revision soon anyway but just wanted to see if we might still be able to sneak this into this initial release.

@develar
Copy link
Member

develar commented Aug 29, 2016

@sfraise Will be pushed in 10-20 minutes after test. And published after push in 10 minutes.

@develar
Copy link
Member

develar commented Aug 29, 2016

If Linux is required for you — feel free to file new issue about it. Currently, no short-term plans to add file associations for Linux and new issue about it will be an indicator of interest. In the original description stated only "allow you to create file association on OS X and Windows separately".

Custom icon files for macOS is not yet copied correctly — will be fixed in the next patch release (please note — defaults to application icon in any case).

@sfraise
Copy link

sfraise commented Aug 29, 2016

Sweet, you rock @develar!

@sfraise
Copy link

sfraise commented Aug 29, 2016

I'm getting an error trying to build on windows now when setting perMachine: true in the package.json file, any ideas?

@develar
Copy link
Member

develar commented Aug 29, 2016

@sfraise It seems that you also set oneClick to false. Such combination was not initially supported and so, not tested (no tests at all). #700

@sfraise
Copy link

sfraise commented Aug 29, 2016

No, I have oneClick: true set

@develar
Copy link
Member

develar commented Aug 29, 2016

@sfraise Please try 6.3.0 and if you still get error, please file new issue with error message

@sfraise
Copy link

sfraise commented Aug 29, 2016

no joy

@sfraise
Copy link

sfraise commented Aug 29, 2016

Fyi I'm using the szwacz electron boilerplate but wouldn't think that should matter? Here's my full package.json...

{
  "build": {
    "appId": "com.elite.planner",
    "app-category-type": "public.app-category.business",
    "win": {
      "target": [
        "nsis"
      ],
      "icon": "resources/windows/icon.ico"
    },
    "nsis": {
      "oneClick": true,
      "installerHeaderIcon": "resources/windows/setup-icon.ico"
    },
    "mac": {
      "icon": "resources/osx/icon.icns"
    },
    "dmg": {
      "target": [
        "nsis"
      ],
      "icon": "resources/osx/dmg-icon.icns",
      "background": "resources/osx/dmg-background.png"
    },
    "fileAssociations": {
      "ext": "elite",
      "name": "ELITE"
    }
  },
  "directories": {
    "buildResources": "resources"
  },
  "scripts": {
    "postinstall": "install-app-deps",
    "build": "gulp build",
    "prerelease": "gulp build --env=production",
    "release": "build --x64 --publish never",
    "start": "gulp start",
    "pretest": "gulp build-unit --env=test",
    "test": "electron-mocha app/specs.js.autogenerated --renderer --require source-map-support/register",
    "pree2e": "gulp build-e2e --env=test",
    "e2e": "mocha app/e2e.js.autogenerated --require source-map-support/register"
  },
  "devDependencies": {
    "chai": "^3.5.0",
    "electron": "1.3.3",
    "electron-builder": "^6.3.0",
    "electron-mocha": "^3.0.0",
    "fs-jetpack": "^0.9.0",
    "gulp": "^3.9.0",
    "gulp-batch": "^1.0.5",
    "gulp-less": "^3.0.3",
    "gulp-plumber": "^1.1.0",
    "gulp-util": "^3.0.6",
    "gulp-watch": "^4.3.5",
    "mocha": "^3.0.2",
    "rollup": "^0.34.7",
    "source-map-support": "^0.4.2",
    "spectron": "^3.3.0",
    "yargs": "^4.2.0"
  }
}

@sfraise
Copy link

sfraise commented Aug 29, 2016

If I put quotes around the true value (ie. "perMachine": "true") the build doesn't fail, haven't verified that the file association is working that way though yet. We shouldn't have to wrap a true/false value in quotes here correct?

@develar
Copy link
Member

develar commented Aug 30, 2016

We shouldn't have to wrap a true/false value in quotes here correct?

Yes, must be not wrapped. Please file new issue and attach build log. Without error message I cannot help you.

@sfraise
Copy link

sfraise commented Aug 30, 2016

Well that seems to also be a problem, I was going to copy the npm-debug.log last night with the other stuff but for some reason its not writing it which is strange because it was before if a build failed. In my ide there is a blank spot where a file should be but no file.

Here's a screen shot of the error I get in the command line:
electron-error

Just out of curiosity I set up a fresh new project and electron boilerplate install and got the same thing. Does electron builder use Visual Studio assets to actually do the build and could it be some issue with my VS setup?

@develar
Copy link
Member

develar commented Aug 30, 2016

@sfraise Please create separate issue — please don't mix.

Just out of curiosity I set up a fresh new project and electron boilerplate install and got the same thing.

Please create new separate issue and attach sample project, I will test it.

@sfraise
Copy link

sfraise commented Aug 31, 2016

See new issue #715

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