【发布时间】:2011-07-20 14:09:04
【问题描述】:
我知道有几篇关于 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 时没有任何反应。这些文件不像以前那样出现在他们的文件夹中,也没有安装任何东西。谁能告诉我哪里出错了?如前所述,网上有几种关于类似问题的解决方案,但到目前为止没有一个对我有用
更新
我尝试在打开日志的情况下安装 msi,日志返回以下 2 行:
CAQuietExec64:错误 0x80070057:无法获取命令行数据
CAQuietExec64:错误 0x80070057:无法获取命令行
在网上搜索了该错误代码的修复程序后,我仍然没有找到任何有助于解决问题的答案。有人有什么想法吗?有 Wix 专家吗?
提前致谢
【问题讨论】:
-
通过生成安装日志开始故障排除(运行 msiexec.exe /i {your msi file here} /log {path to log}。
标签: powershell wix