利用WIX制作安装包(3)
利用WIX安装服务非常简单。只需要短短几句话就可以。当我们创建好一个Windows服务之后。我们在项目中创建一个Service.wxs 文件来安装服务,并且编辑代码如下:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<Component Id="ProductC" Guid="DE8DD064-C440-4E82-80D7-D05C98753DAF" Directory="PRODUCTC">
<File Id="ProductCService" Source="$(var.ProductC.TargetDir)ProductC.exe"/>
<ServiceInstall Id="ProductCServiceInstaller"
Type="ownProcess"
Name="ProductC"
DisplayName="ProductC"
Description="ProductC"
Start="auto"
Account="LocalSystem"
ErrorControl="ignore">
<ServiceConfig DelayedAutoStart="no" OnInstall="yes" />
</ServiceInstall>
<ServiceControl Id="ProductCServiceControl"
Start="install"
Stop="both"
Remove="uninstall"
Name="ProductC"
Wait="yes" />
</Component>
</Fragment>
</Wix>
在上述的例子中我们安装了一个名为ProductC 的服务到系统。并且添加了一个ServiceControl 去控制他的行为。然后我们把这个组件关联到产品的某个Feature之后,当产品安装的时候服务就会自定安装。
然而在某些情况用TopShelf实现的服务,我们无法用WIX安装。这个时候我们需要在服务的项目中添加一个ServiceInstall.cs 文件,并添加如下代码。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Threading.Tasks;
namespace DitronicsHISvr
{
[RunInstaller(true)]
public class HardwareServiceInstaller : Installer
{
public ServiceInstaller ServiceInstaller;
public ServiceProcessInstaller ServiceProcessInstaller;
public HardwareServiceInstaller()
{
this.InitializeComponent();
}
private void InitializeComponent()
{
ServiceInstaller = new ServiceInstaller();
ServiceProcessInstaller = new ServiceProcessInstaller();
this.ServiceProcessInstaller.Account = ServiceAccount.LocalService;
ServiceInstaller.Description = "Service used to interface with Bill Validators.";
ServiceInstaller.DisplayName = "Ditronics HI Server";
ServiceInstaller.ServiceName = "DitronicsHISvr";
this.Installers.AddRange(new Installer[] { this.ServiceProcessInstaller, this.ServiceInstaller });
}
}
}
添加上述代码之后,我们就可以正常的使用WIX进行安装服务了。服务上述代码中的ServiceName和Description一定要和WIX中的ServiceName和description一致。不然会出现服务安装好了,无法启动的bug。
利用WIX制作安装包(3)的更多相关文章
- 利用WIX制作安装包(2)
原文 利用WIX制作安装包(2) 这一篇文章将为大家介绍如何使用WIX自定义UI.上一篇文章我们讲过WIX为我们提供了五种安装界面.每种安装界面都是由不同的Dialog组成.在这里我们挑选一种比较常用 ...
- 利用WIX制作安装包(1)
原文 利用WIX制作安装包(1) #installation 下载最新版本的WIX toolset 并安装DOWNLOAD Wix toolset V3.5之后的版本已经可以集成到visual stu ...
- Wix制作安装包
Wix制作安装包,找起资料来很费劲,记录一下: Product.wxs,该文件只能制作出msi形式的安装包,不能做到自动检测framework. <?xml version="1.0& ...
- 【原创】VB6.0应用程序安装包的生成(Setup Factory 9.0制作安装包的方法)
VB6.0应用程序安装包的生成,利用其自带的打包工具生成的安装程序很简陋,一点不美观:如果想让自己的应用程序安装的时候显得高大上一点,本教程提供使用Setup Factory 9.0制作安装包的方法. ...
- 循序渐进做项目系列(5):制作安装包,谁人都可以!——VS制作安装包简明教程
一开始让我做安装包的时候,其实我是拒绝的.因为我根本就不会做安装包.查了资料之后,我很懵,很晕,很乱,因为不清晰,不简明,不直白.然而经过一番彷徨的挣扎,我终于发现:制作安装包,谁人都可以!故挥狼毫, ...
- 使用Qt installer framework制作安装包
一.介绍 使用Qt库开发的应用程序,一般有两种发布方式:(1)静态编译发布.这种方式使得程序在编译的时候会将Qt核心库全部编译到一个可执行文件中.其优势是简单单一,所有的依赖库都集中在一起,其缺点也很 ...
- VS 制作安装包小窥
难得忙里偷闲,看到有关VS制作安装包,按下文小试一把,还行,比不上Installshield. 首先在打开 VS2010 > 文件 >新建项目 创建一个安装项目 XXX 在“目 ...
- vs2015 制作安装包额外需要安装的软件VSI_bundle
vs2015 制作安装包额外需要安装的软件VSI_bundle 下载地址:http://files.cnblogs.com/files/sdner/VSI_bundle.rar
- [转载]如何用Visual Studio制作安装包
原文地址:如何用Visual Studio制作安装包作者:蓝羽幽游 环境:Microsoft Visual Studio 2010 语言:C# 构架:.NET Framework 2.0 解决方案名称 ...
随机推荐
- Ubuntu su 认证失败
在使用Ubuntu作为开发环境时经常须要在全局安装一些依赖框架等.这个时候就经常须要用到root权限.可是在Ubuntu下第一次使用su命令时会提示认证失败:查找资料后发现Ubuntu下root权限默 ...
- 解决Centos7 下 root账号 远程连接FTP,vsftpd 提示 530 Login incorrect 问题
原文:解决Centos7 下 root账号 远程连接FTP,vsftpd 提示 530 Login incorrect 问题 三步走: 1.vim /etc/vsftpd/user_list 注释掉 ...
- swf loading 自身
stop(); import flash.net.URLRequest; import caurina.transitions.Tweener; loaderInfo.addEventListener ...
- <a href='javacript:' title='{$str}'>是什么意思(多看学习视频)
<a href='javacript:' title='{$str}'>是什么意思(多看学习视频) 一.总结 一句话总结: 1.javascript:是什么? 伪协议,后面接javascr ...
- 前端,Java,产品经理,微信小程序,Python等资源合集大放送
为了感恩大家长久以来的关注和支持,小编准备了一些福利,整理了包含前端,Java,产品经理,微信小程序,Python,网站源码,Android应用视频教程,微信公众平台开发教程及材料等资源合集大放送. ...
- 【t042】炮击坦克
Time Limit: 1 second Memory Limit: 128 MB [问题描述] 在一个坐标轴上,有M辆坦克,第i辆坦克在时刻0处于pos[i](pos[i]>0),speed[ ...
- Expression Blend 的点滴(4)--创建类似iPhone屏幕锁控件(上)
原文:Expression Blend 的点滴(4)--创建类似iPhone屏幕锁控件(上) 本篇文章,最终效果图: 当然,不只是一个UI而已,如果只是一张图片,那专业的设计师能做出更出色的效果.在 ...
- Identifying a distributed denial of service (DDOS) attack within a network and defending against such an attack
The invention provides methods, apparatus and systems for detecting distributed denial of service (D ...
- MKNetWorkKit的使用(1)
在整个程序中只有一个全局队列 MKNetWorkKit中主要有两个类,MKNetworkEngine和 MKNetworkOperation,MKNetworkOperation就是一个操作,是NSO ...
- 使用lapack图书馆逆矩阵
阿土,直接在代码: #include <string> #include "lapacke.h" #include "lapack_aux.h" i ...