我有一个wix安装程序,用于安装Windows服务。
我不是wix的专家,但是我已经对其进行了一些手动修改。我必须进行一次手动编辑,而且我确定有一种方法可以使其自动进行。
我所有的本地化值都在Common.wxl中
然后我有以下文件:
Directories.wxs
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="ROOTDIRECTORY" Name="!(loc.Company)" >
<Directory Id="INSTALLFOLDER" Name="!(loc.ProductName)" />
</Directory>
</Directory>
</Directory>
</Fragment>
</Wix>
Product.wxs
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<?define ProductCode = "!(loc.ProductCode)" ?>
<?define UpgradeCode = "!(loc.ProductUpgradeCode)" ?>
<Product Id="$(var.ProductCode)"
Name="!(loc.ProductName)"
Language="!(loc.Language)"
Version="$(var.BuildVersion)"
Manufacturer="!(loc.Company)"
UpgradeCode="$(var.UpgradeCode)">
<Package InstallerVersion="200"
Compressed="yes"
InstallScope="perMachine"
InstallPrivileges="elevated"
Platform="$(var.Platform)"
Manufacturer="!(loc.Company)"
Description="!(loc.Description)"
Keywords="!(loc.Keywords)"
Comments="!(loc.Comments)"
Languages="!(loc.Language)"/>
<Upgrade Id="$(var.UpgradeCode)">
<UpgradeVersion OnlyDetect="no" Property="PREVIOUSFOUND"
Minimum="1.0.0.0" IncludeMinimum="yes"
Maximum="99.0.0.0" IncludeMaximum="no" />
</Upgrade>
<InstallExecuteSequence>
<RemoveExistingProducts After="InstallInitialize" />
</InstallExecuteSequence>
<MediaTemplate EmbedCab="yes" />
<UIRef Id="WixUI_Minimal"/>
<WixVariable Id="WixUIDialogBmp" Value="$(var.ProjectDir)\Assets\Background.bmp" />
<WixVariable Id="WixUIBannerBmp" Value="$(var.ProjectDir)\Assets\Banner.bmp" />
<WixVariable Id="WixUILicenseRtf" Value="$(var.ProjectDir)\Assets\License.rtf" />
<DirectoryRef Id="TARGETDIR">
<Component Id="RegistryEntries" Guid="!(loc.RegistryEntryGuid)">
<RegistryKey Root="HKLM"
Key="Software\Microsoft\!(loc.RegistryPathName)"
Action="createAndRemoveOnUninstall">
<!-- some registry entries -->
</RegistryKey>
</Component>
</DirectoryRef>
<Feature Id="MainApplication" Title="!(loc.ProductName).Installer" Level="1">
<ComponentGroupRef Id="PublishedComponents" />
<ComponentRef Id="RegistryEntries" />
</Feature>
</Product>
</Wix>
有趣的是,在我的.wixproj项目文件中,
<Target Name="BeforeBuild">
<GetAssemblyIdentity AssemblyFiles="path to exe">
<Output TaskParameter="Assemblies" ItemName="AssemblyVersion" />
</GetAssemblyIdentity>
<PropertyGroup>
<DefineConstants>BuildVersion=%(AssemblyVersion.Version);BasePath=path to bin</DefineConstants>
</PropertyGroup>
<HeatDirectory OutputFile="ComponentsGenerated.wxs" DirectoryRefId="INSTALLFOLDER" ComponentGroupName="PublishedComponents" SuppressCom="true" Directory="path to bin" SuppressFragments="true" SuppressRegistry="true" SuppressRootDirectory="true" AutoGenerateGuids="false" GenerateGuidsNow="true" ToolPath="$(WixToolPath)" PreprocessorVariable="var.BasePath" />
</Target>
在构建之前,上面的代码会生成一个名为ComponentsGenerated.wxs的文件,该文件是我所有文件的列表。看起来像:
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<DirectoryRef Id="INSTALLFOLDER">
<!-- a whole bunch of files like this -->
<Component Id="cmpFF62573AB15AD08779066FDC3C1AC28B" Guid="{E37D2A6F-611F-4052-9BD8-8522E48425C8}">
<File Id="fil48CE70414C67DCC722C2BFF64019C7BE" KeyPath="yes" Source="$(var.BasePath)\a file" />
</Component>
</DirectoryRef>
</Fragment>
<Fragment>
<ComponentGroup Id="PublishedComponents">
<!-- one of the following for each file -->
<ComponentRef Id="cmpFF62573AB15AD08779066FDC3C1AC28B" />
</ComponentGroup>
</Fragment>
</Wix>
但是,由于我正在安装服务,因此我发现我首先必须生成ComponentsGenerated.wxs,然后禁用之前的构建脚本,并进入并找到exe文件并手动添加ServiceInstall和ServiceControl。 / p>
<Component Id="cmpC7DFBA3D2A118C1CD373EB57AEF18B3B" Guid="{29783363-CE4A-4D90-9A3D-83C982635E2F}">
<File Id="filD6AFA5D93A633BDDB8270F84A0DF5CE9" KeyPath="yes" Source="$(var.BasePath)\my exe file" />
<ServiceInstall Id="ServiceInstaller"
Type="ownProcess"
Vital="yes"
Name="name"
DisplayName="name"
Description="name"
Start="auto"
Account="LocalSystem"
Interactive="no"
ErrorControl="normal"/>
<ServiceControl Id="StartService"
Start="install"
Stop="both"
Remove="uninstall"
Name="name"
Wait="yes"/>
</Component>
因为没有“ FileRef”,所以我看不到如何仍然可以使用HeatDirectory生成文件列表,然后将ServiceInstall和ServiceControl添加到exe的文件ID中。