原文:使用WIX打包客户端程序

用WPF为客户做了个小工具,打包的时候发现VS2012居然没有安装项目了,搜了下才知道现在推荐使用WIX来打包了http://wix.sourceforge.net/,我用的最新3.7的。

研究了下,发现有两个要点要记录下来,一是对简体中文的支持,二是自动安装.net Framework的支持;希望大家用到该工具的时候不要再走我的弯路。

1.对简体中文的支持,在这里http://www.cnblogs.com/wfwup/archive/2009/07/16/1524708.html下载的中文资源包,加入到项目里重新编译就可以了,原作者提供的是3.0的,发现在3.7下一样能用,感谢技术手札提供。

把我的Product.wxs文件和大家分享下:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:netfx="http://schemas.microsoft.com/wix/NetFxExtension"> <Product Id="9C505667-71C4-40C7-8B60-2F186920158C" Name="产品名称" Language="2052" Codepage="936" Version="1.0.0.0" Manufacturer="公司名称" UpgradeCode="3b259853-ebce-47cf-aeef-ef4ef089a080">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate/>
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />
<UIRef Id="WixUI_InstallDir" />
<Feature Id="ProductFeature" Title="OfflineViewer" Level="1">
<ComponentGroupRef Id="ProductComponents" />
<ComponentGroupRef Id="ShortcutComponents" />
</Feature>
</Product> <Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="OfflineViewer" />
</Directory>
<Directory Id="ProgramMenuFolder">
<Directory Id="ShortcutMenuFolder" Name="产品名称" />
</Directory>
</Directory>
</Fragment> <Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
<!-- <Component Id="ProductComponent"> -->
<!-- TODO: Insert files, registry keys, and other resources here. -->
<Component Id='ProductComponent' DiskId='1' Guid='6D98C7EE-6EF9-4747-8D03-E7AD0B6122BD'>
<File Name='CommonConfig.xml' Source="$(var.EIAC.AccountingArchivess.OfflineViewer.TargetDir)" />
<File Name='EIAC.AccountingArchivess.OfflineViewer.CustomControl.dll' Source="$(var.EIAC.AccountingArchivess.OfflineViewer.TargetDir)" />
<File Name='Offline.Common.dll' Source="$(var.EIAC.AccountingArchivess.OfflineViewer.TargetDir)" />
<File Name='EIAC.AccountingArchivess.OfflineViewer.exe' Source="$(var.EIAC.AccountingArchivess.OfflineViewer.TargetDir)" />
</Component>
<!-- </Component> -->
</ComponentGroup> <ComponentGroup Id="ShortcutComponents" Directory="ShortcutMenuFolder">
<Component Id="ApplicationShortcut" Guid="C919F5ED-D2B3-42E8-9F7C-63269274FE79">
<Shortcut Id="ApplicationStartMenuShortcut" Name="产品名称" Target="[INSTALLFOLDER]EIAC.AccountingArchivess.OfflineViewer.exe" WorkingDirectory="INSTALLFOLDER" />
<RemoveFolder Id="ShortcutMenuFolder" On="uninstall" />
<RegistryValue Root="HKCU" Key="Software/公司名称/产品名称" Name="installed" Type="integer" KeyPath="yes" Value="1" />
</Component>
</ComponentGroup>
</Fragment> </Wix>

2.自动安装.net Framework,参考了这篇文章:http://blog.csdn.net/duanzilin/article/details/5982296

用文本编辑器打开项目文件*.wixproj,在Project节点加入如下xml(请大家选择自己需要的.net版本)

 <ItemGroup>
<BootstrapperPackage
Include=".NETFramework,Version=v4.0,Profile=Client">
<Visible>False</Visible>
<ProductName>.NET Framework 4.0 Client</ProductName>
<Install>True</Install>
</BootstrapperPackage>
</ItemGroup>

<Target Name="AfterBuild">
<GenerateBootstrapper ApplicationFile="zh-cn\$(TargetFileName)"
ApplicationName="产品名称"
BootstrapperItems="@(BootstrapperPackage)"
ComponentsLocation="Relative"
CopyComponents="True"
OutputPath="$(OutputPath)"
Path="C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bootstrapper\"/>
</Target>

保存,重新编译即可。那个Bootstrapper目录请大家按照自己电脑上的目录结构修改(一般好像都一样的)

Wix中添加自定义操作部分,因项目没用上也没研究。

最新文章

  1. Windows 8 下离线安装。net Framework 3.5
  2. Sublime Text安装Package Control
  3. Word: How to Temporarily Disable Spell Check in Word
  4. hibernate的二级缓存
  5. Message Queue vs. Web Services?
  6. linux下文件合并、分割、去重
  7. [C和指针] rearrange.c
  8. 网络语音视频技术浅议(附多个demo源码下载)
  9. Spring 日期时间处理
  10. CSharpGL(45)自制控件的思路
  11. linux进程、线程与cpu的亲和性(affinity)
  12. Azkaban学习之路 (三)Azkaban的使用
  13. matplotlib 入门之Usage Guide
  14. CORS(Cross-origin resource sharing) “跨域资源共享”
  15. CentOS 安装Nginx1.14.0
  16. 实验二:MAL——简单后门 by:赵文昊
  17. Qt程序ibus输入法不跟随
  18. 流程控制语句 if
  19. 第三方网站返回hybrid app H5页面缓存问题应对策略
  20. Android 4.0 Tabhost图标显示不出来

热门文章

  1. sqlserver 存储过程实例
  2. 高性能JavaScript模板引擎原理解析
  3. sed 技巧一例:特定位置插入
  4. 【每日一摩斯】-Troubleshooting: High CPU Utilization (164768.1) - 系列4
  5. 原始的js代码和jquery对比
  6. C keyword register 并讨论共同使用嵌入式汇编
  7. pc2日记——有惊无险的第二天2014/08/29
  8. MFC的消息反射机制
  9. Visual Studio 控件命名规范(很详细)
  10. 8086 CPU 寻址方式