Question

I'm currently using cfx xpi to package my add-on to a .xpi file, as instructed here in the Add-on SDK Development Guide.

I would now like to build my code on a machine where the Add-on SDK is not present, which means no Python, and no cfx. Is it possible to do this, preferably from the command line?

I've tried simply zipping up the MyAddon folder to MyAddon.zip, and then renaming it to MyAddon.xpi, but when I try to install it on Firefox, I get the error message "This add-on could not be installed because it appears to be corrupt."

Any and all help appreciated.

Was it helpful?

Solution

Currently, you need the cfx tool to build add-ons if you want to use the Addon SDK. The build process includes mapping dependencies, adding in the bootstrap.js file for restartless addons, and a few files to make it loadable via Firefox. Just zipping it and calling it a xpi won't do the trick.

The Addon-SDK team is looking at options to make the same directory structure that you use for development able to be loaded directly into Firefox, removing the build step: Proposal

I worked on a JS-only builder addon during the SDK work week a few weeks ago that involves an addon essentially building and installing another addon. You can probably pull out components of that and node-ify them if you can run node on your build server. What -is- available on that other machine? What are you trying to accomplish that this set up is necessary, with a machine that doesn't even have python installed?

OTHER TIPS

OK I figured out how to manually create .xpi Firefox extensions after about an hour of frustrating trial and error.

The file structure that Firefox creates for all .xpi when you run cfx run is this:

myfirefoxaddonname.zip
   -> bootstrap.js
   -> defaults
         -> preferences
                 -> prefs.js NOTE: Empty by default
   -> harness-options.json
   -> resources
         -> myfirefoxaddonname
                  -> data
                          -> your stuff (CSS, JS, etc.) goes here
                  -> lib
                          -> main.js
                  -> test
   -> package.json
   -> install.rdf
   -> locales.json  NOTE: has one line by default: {"locales": []}
   -> locale NOTE: Empty by default

Some of these files/folders are unnecessary (e.g. the test folder), but I've included because that's the default format Firefox .xpi add-ons require.

The way I found this out was by running cfx xpi, then navigating to the created .xpi file, renaming it a .zip, and unzipping it to see its contents.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top