Electron electron-winstaller 为Msi设置安装路径
Electron electron-winstaller Set Installation Path for Msi
我正在使用 Electron 和 Angular2 为 Windows 创建桌面应用程序,并且可以成功生成用于安装的 .exe 和 .msi 文件。我使用 electron-packager 来打包我的 electron 应用程序
packaged electron app
打包应用程序后,我使用 electron-winstaller 从包中生成一个 msi
当我 运行 .msi 文件时,它会自动将我的项目安装到 C:\Users\Username\AppData\Local\ApplicationName 。双击 msi 时唯一的事情就是这个简短的对话框:
dialog
不过,我想要的是让安装程序提示我应该安装应用程序的位置。我希望安装的时候可以设置安装路径
我还应该提一下,我尝试使用 electron-builder,也可以生成 msi 文件。但是这里我也无法设置安装路径。我发现这个 Electron create MSI installer using electron-builder 问题,其他人对 electron-builder 也有同样的问题,但他的问题没有答案。
这是我对 electron-winstaller 的配置。 winstaller.js 文件位于我项目的根目录:
var electronInstaller = require('electron-winstaller');
var resultPromise = electronInstaller.createWindowsInstaller(
{
appDirectory: '../installer/sda-win32-x64',
outputDirectory: '../installer',
authors: 'SORA Desktop Application',
exe: 'sda.exe',
setupExe: 'SDASetup.exe',
setupMsi: 'SDASetup.msi',
iconUrl: 'file:///d/dev/sda/client/src/app/assets/images/icon.ico',
setupIcon: 'src/app/assets/images/icon.ico'
});
resultPromise.then(() => console.log('It worked!'), e => console.log(`No dice: ${e.message}`));
这是我的 package.json 配置。这也位于我项目的根目录
{
"name": "sda",
"description": "SDA 3.0",
"version": "0.0.1",
"main": "gulpfile.js",
"keywords": [
"Angular",
"Angular2",
"Electron",
"Typescript"
],
"author": "Vic",
"license": "MIT",
"scripts": {
"build": "gulp build",
"start": "npm run build && electron ./dist/index.js",
"package": "npm run build && gulp electron:package",
"postinstall": "concurrently \"bower install\" \"typings install\"",
"appstart": "electron ./dist/index.js",
"test": "gulp test",
"deploy": "rm -rf ../installer && gulp setInDevelopmentFlagToFalse && cp src/app/environment/environment.prod.ts src/app/environment/environment.ts && npm run build && cd dist && electron-packager . --platform=win32 --arch=x64 --overwrite=true --out=../../installer --icon=assets/images/icon.ico && cd ../ && gulp setInDevelopmentFlagToTrue && cp src/app/environment/environment.dev.ts src/app/environment/environment.ts && node winstaller.js"
},
"dependencies": {
"@angular/common": "2.0.0",
"@angular/compiler": "2.0.0",
"@angular/core": "2.0.0",
"@angular/forms": "2.0.0",
"@angular/http": "2.0.0",
"@angular/platform-browser": "2.0.0",
"@angular/platform-browser-dynamic": "2.0.0",
"@angular/router": "3.0.0",
"@angular/upgrade": "2.0.0",
"@ng-bootstrap/ng-bootstrap": "1.0.0-alpha.8",
"@types/hammerjs": "2.0.33",
"@types/sjcl": "1.0.27",
"angular2-jwt": "0.1.23",
"angular2-moment": "1.0.0-beta.5",
"angular2localization": "1.0.2",
"bootstrap": "4.0.0-alpha.4",
"core-js": "2.4.1",
"file-saver": "1.3.3",
"font-awesome": "4.6.3",
"jquery": "3.1.1",
"moment": "2.15.2",
"normalize.css": "5.0.0",
"reflect-metadata": "0.1.3",
"rxjs": "5.0.0-beta.12",
"sjcl": "1.0.6",
"systemjs": "0.19.27",
"tether": "1.3.7",
"zone.js": "0.6.23"
},
"devDependencies": {
"bower": "1.7.9",
"concurrently": "2.2.0",
"del": "2.2.0",
"electron": "1.3.5",
"electron-connect": "0.6.0",
"electron-packager": "8.1.0",
"electron-prebuilt": "1.3.8",
"electron-winstaller": "2.3.4",
"eslint": "3.6.0",
"eslint-config-google": "0.6.0",
"eslint-plugin-html": "1.5.3",
"gulp": "3.9.1",
"gulp-atom-electron": "1.9.0",
"gulp-concat": "2.6.0",
"gulp-replace": "^0.5.4",
"gulp-sass": "2.3.1",
"gulp-shell": "0.5.2",
"gulp-symdest": "1.0.0",
"gulp-typescript": "3.0.2",
"hammerjs": "2.0.8",
"jasmine-core": "2.5.2",
"karma": "1.3.0",
"karma-chrome-launcher": "2.0.0",
"karma-cli": "1.0.1",
"karma-htmlfile-reporter": "0.3.4",
"karma-jasmine": "1.0.2",
"karma-jasmine-html-reporter": "0.2.2",
"karma-sourcemap-loader": "0.3.7",
"karma-typescript-preprocessor": "0.3.0",
"run-sequence": "1.1.5",
"typescript": "2.0.2",
"typings": "1.3.2"
}
}
我可能需要证书吗?
windows 安装程序询问安装位置不是默认设置吗?
electron-winstaller 使用 squirrel 生成安装文件。根据他们的 documentation,安装路径是 "effectively immutable" 并且硬设置为 \%LocalAppData%\AppName :
Install Location
The Setup.exe, and later the UpdateManager in MyApp must have the
ability to write files to and execute files from the application
install location. To ensure permission for all types of users, the
user's application data directory is selected as the install location
(i.e., %LocalAppData%\MyApp).
The installation root really only needs to consist of two types of
folders:
Packages - folder used to download and assemble the update package
files. App Folders - the "installed" application files for a given
version of MyApp. \%LocalAppData%\MyApp \packages
MyApp-1.0.0.nupkg
MyApp-1.0.1-delta.nupkg
MyApp-1.0.1.nupkg \app-1.0.0
MyApp.exe \app-1.0.1
MyApp.exe The packages directory is effectively immutable, it simply consists of the packages we've downloaded. Using the user's
local application data directory means that we the needed write-access
to the install directory on a per-user basis.
Tip: See Machine-wide Installs for more information on ensuring your
application pushed to all users in an enterprise environment.
在机器范围内安装的方法是使用仅在下次用户登录时触发安装的 MSI:
Machine-wide Installs
Squirrel's Releasify command generates an MSI file suitable for
installation via Group Policy. This MSI isn't a general-purpose
installer, this means that once you run the MSI, users from now on
will get the app installed, on next Login.
So, most normal users should continue to run the Setup.exe's generated
by Releasify, but if you want to have an IT Admin Friendly version,
you can hand off the MSI
Most users of Squirrel won't have to do anything new to enable this
behavior, though certain NuGet package IDs / names might cause
problems with MSI.
我正在使用 Electron 和 Angular2 为 Windows 创建桌面应用程序,并且可以成功生成用于安装的 .exe 和 .msi 文件。我使用 electron-packager 来打包我的 electron 应用程序 packaged electron app
打包应用程序后,我使用 electron-winstaller 从包中生成一个 msi
当我 运行 .msi 文件时,它会自动将我的项目安装到 C:\Users\Username\AppData\Local\ApplicationName 。双击 msi 时唯一的事情就是这个简短的对话框: dialog
不过,我想要的是让安装程序提示我应该安装应用程序的位置。我希望安装的时候可以设置安装路径
我还应该提一下,我尝试使用 electron-builder,也可以生成 msi 文件。但是这里我也无法设置安装路径。我发现这个 Electron create MSI installer using electron-builder 问题,其他人对 electron-builder 也有同样的问题,但他的问题没有答案。
这是我对 electron-winstaller 的配置。 winstaller.js 文件位于我项目的根目录:
var electronInstaller = require('electron-winstaller');
var resultPromise = electronInstaller.createWindowsInstaller(
{
appDirectory: '../installer/sda-win32-x64',
outputDirectory: '../installer',
authors: 'SORA Desktop Application',
exe: 'sda.exe',
setupExe: 'SDASetup.exe',
setupMsi: 'SDASetup.msi',
iconUrl: 'file:///d/dev/sda/client/src/app/assets/images/icon.ico',
setupIcon: 'src/app/assets/images/icon.ico'
});
resultPromise.then(() => console.log('It worked!'), e => console.log(`No dice: ${e.message}`));
这是我的 package.json 配置。这也位于我项目的根目录
{
"name": "sda",
"description": "SDA 3.0",
"version": "0.0.1",
"main": "gulpfile.js",
"keywords": [
"Angular",
"Angular2",
"Electron",
"Typescript"
],
"author": "Vic",
"license": "MIT",
"scripts": {
"build": "gulp build",
"start": "npm run build && electron ./dist/index.js",
"package": "npm run build && gulp electron:package",
"postinstall": "concurrently \"bower install\" \"typings install\"",
"appstart": "electron ./dist/index.js",
"test": "gulp test",
"deploy": "rm -rf ../installer && gulp setInDevelopmentFlagToFalse && cp src/app/environment/environment.prod.ts src/app/environment/environment.ts && npm run build && cd dist && electron-packager . --platform=win32 --arch=x64 --overwrite=true --out=../../installer --icon=assets/images/icon.ico && cd ../ && gulp setInDevelopmentFlagToTrue && cp src/app/environment/environment.dev.ts src/app/environment/environment.ts && node winstaller.js"
},
"dependencies": {
"@angular/common": "2.0.0",
"@angular/compiler": "2.0.0",
"@angular/core": "2.0.0",
"@angular/forms": "2.0.0",
"@angular/http": "2.0.0",
"@angular/platform-browser": "2.0.0",
"@angular/platform-browser-dynamic": "2.0.0",
"@angular/router": "3.0.0",
"@angular/upgrade": "2.0.0",
"@ng-bootstrap/ng-bootstrap": "1.0.0-alpha.8",
"@types/hammerjs": "2.0.33",
"@types/sjcl": "1.0.27",
"angular2-jwt": "0.1.23",
"angular2-moment": "1.0.0-beta.5",
"angular2localization": "1.0.2",
"bootstrap": "4.0.0-alpha.4",
"core-js": "2.4.1",
"file-saver": "1.3.3",
"font-awesome": "4.6.3",
"jquery": "3.1.1",
"moment": "2.15.2",
"normalize.css": "5.0.0",
"reflect-metadata": "0.1.3",
"rxjs": "5.0.0-beta.12",
"sjcl": "1.0.6",
"systemjs": "0.19.27",
"tether": "1.3.7",
"zone.js": "0.6.23"
},
"devDependencies": {
"bower": "1.7.9",
"concurrently": "2.2.0",
"del": "2.2.0",
"electron": "1.3.5",
"electron-connect": "0.6.0",
"electron-packager": "8.1.0",
"electron-prebuilt": "1.3.8",
"electron-winstaller": "2.3.4",
"eslint": "3.6.0",
"eslint-config-google": "0.6.0",
"eslint-plugin-html": "1.5.3",
"gulp": "3.9.1",
"gulp-atom-electron": "1.9.0",
"gulp-concat": "2.6.0",
"gulp-replace": "^0.5.4",
"gulp-sass": "2.3.1",
"gulp-shell": "0.5.2",
"gulp-symdest": "1.0.0",
"gulp-typescript": "3.0.2",
"hammerjs": "2.0.8",
"jasmine-core": "2.5.2",
"karma": "1.3.0",
"karma-chrome-launcher": "2.0.0",
"karma-cli": "1.0.1",
"karma-htmlfile-reporter": "0.3.4",
"karma-jasmine": "1.0.2",
"karma-jasmine-html-reporter": "0.2.2",
"karma-sourcemap-loader": "0.3.7",
"karma-typescript-preprocessor": "0.3.0",
"run-sequence": "1.1.5",
"typescript": "2.0.2",
"typings": "1.3.2"
}
}
我可能需要证书吗? windows 安装程序询问安装位置不是默认设置吗?
electron-winstaller 使用 squirrel 生成安装文件。根据他们的 documentation,安装路径是 "effectively immutable" 并且硬设置为 \%LocalAppData%\AppName :
Install Location
The Setup.exe, and later the UpdateManager in MyApp must have the ability to write files to and execute files from the application install location. To ensure permission for all types of users, the user's application data directory is selected as the install location (i.e., %LocalAppData%\MyApp).
The installation root really only needs to consist of two types of folders:
Packages - folder used to download and assemble the update package files. App Folders - the "installed" application files for a given version of MyApp. \%LocalAppData%\MyApp \packages MyApp-1.0.0.nupkg MyApp-1.0.1-delta.nupkg MyApp-1.0.1.nupkg \app-1.0.0 MyApp.exe \app-1.0.1 MyApp.exe The packages directory is effectively immutable, it simply consists of the packages we've downloaded. Using the user's local application data directory means that we the needed write-access to the install directory on a per-user basis.
Tip: See Machine-wide Installs for more information on ensuring your application pushed to all users in an enterprise environment.
在机器范围内安装的方法是使用仅在下次用户登录时触发安装的 MSI:
Machine-wide Installs
Squirrel's Releasify command generates an MSI file suitable for installation via Group Policy. This MSI isn't a general-purpose installer, this means that once you run the MSI, users from now on will get the app installed, on next Login.
So, most normal users should continue to run the Setup.exe's generated by Releasify, but if you want to have an IT Admin Friendly version, you can hand off the MSI
Most users of Squirrel won't have to do anything new to enable this behavior, though certain NuGet package IDs / names might cause problems with MSI.