我知道有几篇关于 Wix 和 PowerShell 脚本的帖子,但在尝试了这些帖子中的解决方案后,我仍然没有得到我想要的结果。为了解释我的情况,我创建了一个 Wix 安装项目,它将从我的本地计算机(运行 Windows 7)获取 2 个 Powershell 脚本和一个 msu 文件,并将它们捆绑到一个 msi 文件中。如果我在测试虚拟机(运行 Windows Server 2008 r2)上运行 msi 文件,文件将被复制到指定的目录中。伟大的。在“添加/删除程序”列表中显示新项目有一个缺点,但这将是我稍后会处理的问题。
(Powershell 脚本将安装 msu、编辑配置文件并启动服务 - 手动运行时工作正常)
将文件复制到目标计算机后,我尝试做的是运行复制的 Powershell 脚本之一,但到目前为止我还无法实现这一点。
我的 .wxs 代码如下所示(使用 TFS 2010 编写和编译)
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
<Product Id="a89cc681-d617-43ea-817e-1db89b941bf2" Name="Test1" Language="1033" Version="1.0.0.0" Manufacturer="Test1" UpgradeCode="d8db2663-2567-4bb8-9023-09988838eb55">
<Package InstallerVersion="200" Compressed="yes" />
<Media Id="1" Cabinet="media1.cab" EmbedCab="yes" />
<!-- Set up the directory -->
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="IISTIERINSTALLATION" Name="IISTierInstallation">
</Directory>
</Directory>
<!-- Copy the files -->
<DirectoryRef Id="IISTIERINSTALLATION">
<Component Id ="C2WTS_update_file" Guid="11960C39-12EB-4777-B43F-394ADB352DD3">
<File Id="C2WTSmsu" Name="Windows6.1-KB974405-x64.msu" Source="C:\PS Scripts\Windows6.1-KB974405-x64.msu" />
</Component>
<Component Id ="C2WTSInstallScript" Guid="C85ED4DB-BDC1-4DD1-84FE-41D7463C6365">
<File Id="C2WTSscript1" Name="C2WTS_service_install.ps1" Source="C:\PS Scripts\C2WTS_service_install.ps1" />
</Component>
<Component Id ="C2WTSxmlScript" Guid="AF1F85A7-88F7-4BBA-89D9-6817CFAA74F9">
<File Id="C2WTSscript2" Name="Edit_c2wts_config.ps1" Source="C:\PS Scripts\Edit_c2wts_config.ps1" />
</Component>
</DirectoryRef>
<Feature Id="ProductFeature" Title="Test1" Level="1">
<ComponentRef Id="C2WTS_update_file" />
<ComponentRef Id="C2WTSInstallScript" />
<ComponentRef Id="C2WTSxmlScript" />
<ComponentGroupRef Id="Product.Generated" />
</Feature>
<!-- Run custom action to run the powershell script-->
<Property Id="POWERSHELLEXE">
<RegistrySearch Id="POWERSHELLEXE"
Type="raw"
Root="HKLM"
Key="SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell"
Name="Path" />
</Property>
<SetProperty Id="RunPSscript"
After="InstallFiles"
Sequence="execute"
Value =""[POWERSHELL.EXE]" -Version 2.0 -NoProfile -NonInteractive -InputFormat None -ExecutionPolicy Bypass -Command "& '[#C2WTS_service_install.ps1]' ; exit $$($Error.Count)"" />
<CustomAction Id="RunPSscript"
BinaryKey="WixCA"
DllEntry="CAQuietExec"
Execute="deferred"
Return="check"
Impersonate="yes" />
<Custom Action="RunPSscript" After="InstallFiles">
<![CDATA[NOT Installed]]>
</Custom>
</Product>
</Wix>
由于添加了自定义活动来执行 powershell 脚本,因此当我运行 msi 时没有任何反应。这些文件不再像以前那样出现在其文件夹中,并且未安装任何内容。谁能告诉我哪里错了?如前所述,网上有几个关于类似问题的解决方案,但到目前为止没有一个对我有用
UPDATE
我尝试在打开日志记录的情况下安装 msi,日志返回以下 2 行:
CAQuietExec64:错误0x80070057:无法获取命令行数据
CAQuietExec64:错误0x80070057:无法获取命令行
在网上搜索该错误代码的修复程序后,我仍然没有找到任何答案来帮助解决问题。有人有什么想法吗?有 Wix 专家吗?
提前致谢