前置条件检查
先决条件是,
- Visual Studio 2008 IDE 安装。
- Dotnet 框架 2.0 运行时
- GAX 安装。
要检查这些,请参考这两个 DLL:
- WixNetFxExtension(主要来自 C:\Program Files\Windows Installer XML v3\bin\WixNetFxExtension.dll)
- WixUIExtension(主要来自 C:\Program Files\Windows Installer XML v3\bin\WixUIExtension.dll)
并将先决条件添加到您的 .wxs 文件中,如下所示。
<!-- Dotnet 2.0 framework installation check - START -->
<PropertyRef Id="NETFRAMEWORK20" />
<Condition Message="Framework 2.0 is required for the setup to continue."><![CDATA[INSTALLED or NETFRAMEWORK20]]></Condition>
<!-- Dotnet 2.0 framework installation check - END -->
<!-- VS.NET and VS.C# installation check - START -->
<Property Id="VCSHARP">
<RegistrySearch Id="VCShaprp" Root="HKLM" Key="SOFTWARE\Microsoft\VisualStudio\9.0\InstalledProducts\Microsoft Visual C#" Name="Package" Type="raw" />
</Property>
<Condition Message="Please install Visual C# with Visual Studio 2008 to continue. Setup will now abort."><![CDATA[INSTALLED or VCSHARP]]></Condition>
<!-- VS.NET and VS.C# installation check - END -->
<!-- GAX for VS.2008 installation check - START -->
<Property Id="GAX">
<RegistrySearch Id="gax" Root="HKLM" Key="SOFTWARE\Microsoft\VisualStudio\9.0\InstalledProducts\RecipeManagerPackage" Name="Package" Type="raw" />
</Property>
<Condition Message="Please install Guidance Automation Extension on Visual Studio 2008 to continue. Setup will now abort."><![CDATA[INSTALLED OR GAX]]></Condition>
<!-- GAX for VS.2008 installation check - END -->
<!-- Pre-requisite check - END -->
安装文件夹
定义运行时安装文件夹设置。此链接将帮助您回答所有“如何”。
运行安装程序
您必须修改您的 InstallerClass,如下所示。
[System.ComponentModel.ToolboxItem(false)]
[RunInstaller(true)]
public class InstallerClass : ManifestInstaller
{
public InstallerClass()
: base()
{ }
public override void Install(System.Collections.IDictionary stateSaver)
{
base.Install(stateSaver);
}
public override void Commit(System.Collections.IDictionary savedState)
{
base.Commit(savedState);
}
public override void Rollback(System.Collections.IDictionary savedState)
{
base.Rollback(savedState);
}
}
没有这个 WIX 安装程序会抛出一个异常,说没有类被标记为“RunInstaller”
在此之后,您可以使用以下 WIX 元素运行 installutil.exe 来运行您的安装程序类。
<InstallExecuteSequence>
<RemoveExistingProducts After="InstallInitialize" />
<Custom Action="ManagedInstall" After="InstallFinalize" >NOT Installed</Custom>
<Custom Action="ManagedUnInstall" After="InstallInitialize">Installed AND NOT UPGRADINGPRODUCTCODE</Custom>
</InstallExecuteSequence>
<CustomAction Id="ManagedInstall"
Directory='INSTALLLOCATION'
ExeCommand='"[WindowsFolder]Microsoft.NET\Framework\v2.0.50727\installUtil.exe" /LogToConsole=false /DesignMode /hive=9.0 /Configuration="[INSTALLLOCATION]Guidance.xml" "[INSTALLLOCATION]PackageInstaller2008.dll"'
Return='check' >
</CustomAction>
<CustomAction Id="ManagedUnInstall"
Directory='INSTALLLOCATION'
ExeCommand='"[WindowsFolder]Microsoft.NET\Framework\v2.0.50727\installUtil.exe" /u /LogToConsole=false /DesignMode /hive=9.0 /Configuration="[INSTALLLOCATION]Guidance.xml" "[INSTALLLOCATION]PackageInstaller2008.dll"'
Return='check' >
</CustomAction>
希望这可以帮助。