Golang 编写msi,并在windows中注册为服务
2017-12-12 19:51
316 查看
Golang
编写msi,并在windows中注册为服务
这里注意:golang正常的写法,不需要添加任何操作。但是注册windows服务时不能使用sc命令,sc命令需要golang返回信息给sc,这里会报错。
1、编译成msi需要包,安装release版本,go-msi
https://github.com/mh-cbon/go-msi,
2、下载安装wix
http://wixtoolset.org/releases/,
安装完wix之后添加wix的bin目录到环境变量path
3、注册环境变量需要使用nssm,下载nssm到项目目录下,在下面配置文件中会用到http://nssm.cc/download
3、在golang编译好的exe下,放go-msi配置文件wix.json
{
"product":"getmacaddress",
"company": "mh-cbon",
"upgrade-code":"db86ffd8-a4a2-4c4d-8140-c31ff42c9cf7",
"files": {
"guid":"35f3909c-e059-4c2b-ad62-95f21db9c294",
"items": [
"go_build_server_go.exe"
]
},
"directories": [
"nssm-2.24"
],
"env": {
"guid":"c67d8185-d2f8-4912-9081-6c8104a575db",
"vars": [
{
"name": "some",
"value": "value",
"permanent": "no",
"system": "no",
"action": "set",
"part": "last"
}
]
},
"shortcuts": {
"guid":"07411c15-e4c6-4153-b199-450c2e3199c6",
"items": [
{
"name":"go_build_server_go",
"description":"go_build_server_go web server",
"target":"[INSTALLDIR]\\go_build_server_go.exe",
"wdir":"INSTALLDIR",
"arguments": "",
"icon": ""
}
]
},
"choco": {},
"hooks": [
{
"command":"[INSTALLDIR]nssm-2.24\\win32\\nssm.exe install getmacaddress[INSTALLDIR]go_build_server_go.exe",
"when": "install"
},
{
"command": "sc.exe startgetmacaddress",
"when": "install"
},
{
"command": "sc.exe deletegetmacaddress",
"when": "uninstall"
}
]
}
4、在配置文件下运行:go-msiset-guid
5、go-msi make--msi your_program.msi --version 0.0.2会在项目文件夹下生成your_program.msi
6、msi文件安装目录下不能有空格
编写msi,并在windows中注册为服务
这里注意:golang正常的写法,不需要添加任何操作。但是注册windows服务时不能使用sc命令,sc命令需要golang返回信息给sc,这里会报错。
1、编译成msi需要包,安装release版本,go-msi
https://github.com/mh-cbon/go-msi,
2、下载安装wix
http://wixtoolset.org/releases/,
安装完wix之后添加wix的bin目录到环境变量path
3、注册环境变量需要使用nssm,下载nssm到项目目录下,在下面配置文件中会用到http://nssm.cc/download
3、在golang编译好的exe下,放go-msi配置文件wix.json
{
"product":"getmacaddress",
"company": "mh-cbon",
"upgrade-code":"db86ffd8-a4a2-4c4d-8140-c31ff42c9cf7",
"files": {
"guid":"35f3909c-e059-4c2b-ad62-95f21db9c294",
"items": [
"go_build_server_go.exe"
]
},
"directories": [
"nssm-2.24"
],
"env": {
"guid":"c67d8185-d2f8-4912-9081-6c8104a575db",
"vars": [
{
"name": "some",
"value": "value",
"permanent": "no",
"system": "no",
"action": "set",
"part": "last"
}
]
},
"shortcuts": {
"guid":"07411c15-e4c6-4153-b199-450c2e3199c6",
"items": [
{
"name":"go_build_server_go",
"description":"go_build_server_go web server",
"target":"[INSTALLDIR]\\go_build_server_go.exe",
"wdir":"INSTALLDIR",
"arguments": "",
"icon": ""
}
]
},
"choco": {},
"hooks": [
{
"command":"[INSTALLDIR]nssm-2.24\\win32\\nssm.exe install getmacaddress[INSTALLDIR]go_build_server_go.exe",
"when": "install"
},
{
"command": "sc.exe startgetmacaddress",
"when": "install"
},
{
"command": "sc.exe deletegetmacaddress",
"when": "uninstall"
}
]
}
4、在配置文件下运行:go-msiset-guid
5、go-msi make--msi your_program.msi --version 0.0.2会在项目文件夹下生成your_program.msi
6、msi文件安装目录下不能有空格
相关文章推荐
- C++编写及注册windows服务程序
- C++编写及注册windows服务程序
- C++编写及注册windows服务程序
- golang程序在windows上,注册为服务
- 在windows下注册Subversion为系统服务
- C#编写Windows服务的基本过程(转)
- Windows服务编写
- C++语言编写windows服务
- Windows 自定义exe文件注册系统服务方法
- Windows 服务程序编写
- Windows下MongoDb注册为系统服务
- 在 C# 平台中, 编写 Windows 服务的简单例子
- 用C语言编写Windows服务程序的五个步骤
- 用Delphi编写Windows服务(Service)
- windows下tomcat注册成服务/控制台日志输出(tomcat8-stderr.2015-1)
- windows系统服务的注册及运行服务方法
- C# windows 服务编写及安装
- 通 5ae 过JavaService 将java jar包注册成Windows 服务
- 用 C 语言编写 Windows 服务程序的五个步骤
- 注册windows服务小结