WIX - 引用热生成的文件 ID 以用于自定义操作
WIX - Reference a heat generated file ID for use in Custom Action
Wix 新手,但正在努力学习!
我正在使用 heat 生成一个 'directory.wxs' 文件,其中包含我的应用程序所需的所有文件。其中一个文件是 Powershell 脚本,我需要 运行 作为自定义操作。我正在尝试使用 -suid
标志,以便 File Id
在 运行 中保持一致。我不喜欢这个解决方案,因为如果我有两个同名的文件,我可能会遇到麻烦...欢迎对那个提出建议。
在 customaction.wxs 文件中,我尝试使用生成的 "install-service-filebeat.ps1" 作为自定义操作中的 属性 值。我在这里和其他网站上看过很多与此类似的示例/问题。我可能只是个白痴,遗漏了一些东西,但想知道我的问题是从我的 directory.wxs 文件中引用 ID,还是在我的语法中的其他地方。
以下是我的脚本,因为它们很长,所以我把它们放在了最后。
提前致谢!
我的 PS 脚本:
## Powershell Script to Create MSI ##
## Variables ##
# WIX Source Dir #
$WIX_DIR="C:\Program Files (x86)\WiX Toolset v3.11\bin"
# Source Dir for files to be enumerated into MSI #
$SRC_DIR="C:\application-directory"
# Name of our Application #
$APP_NAME="Filebeat"
# Where to stage the various .wxs files #
$STG_DIR="C:\wix-project${APP_NAME}\stage"
# Where to deliver the Final Product #
$TGT_DIR="C:\wix-project${APP_NAME}\output"
## Create MSI ##
# Compile the source files into a Fragment to be referenced by main builder Product.wxs #
& ${WIX_DIR}\heat.exe dir $SRC_DIR -srd -dr INSTALLDIR -cg MainComponentGroup -out ${STG_DIR}\directory.wxs -ke -sfrag -gg -ssuid -var var.SourceDir -sreg -scom
# Convert the .wxs files into .wxobj for consumption by light.exe #
& ${WIX_DIR}\candle.exe -dSourceDir="${SRC_DIR}" ${STG_DIR}\*.wxs -o ${STG_DIR}\ -ext WixUtilExtension -arch x64
# Create the final MSI package --CURRENTLY REFERENCING THE FILES EXPLICITY. NEED TO FIND WAY TO WILDCARD! #
& ${WIX_DIR}\light.exe -o ${TGT_DIR}${APP_NAME}_installer.msi ${STG_DIR}\customaction.wixobj ${STG_DIR}\directory.wixobj ${STG_DIR}\product.wixobj -cultures:en-US -ext WixUIExtension.dll -ext WiXUtilExtension.dll
这很好地生成了我的文件,并编译了它们。我的内容customaction.wxs:
<?xml version='1.0' encoding='windows-1252'?>
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>
<Fragment>
<!--Define the CustomAction for running the PowerShell script-->
<CustomAction Id="RunPowerShellScript_set"
Property="install_service.ps1"
Value=""[\[]POWERSHELLEXE[\]]" -Version 2.0 -NoProfile -NonInteractive -InputFormat None -ExecutionPolicy Bypass -Command "&'4(var.SourceDir)\[\[]#install_service.ps1[\]]'; exit $$($Error.Count)"" />
<CustomAction Id="RunPowerShellScript"
BinaryKey="WixCA"
DllEntry="CAQuietExec"
Execute="deferred"
Return="check"
Impersonate="yes" />
<!-- Ensure PowerShell is installed and obtain the PowerShell executable location -->
<Property Id="POWERSHELLEXE">
<RegistrySearch Id="POWERSHELLEXE"
Type="raw"
Root="HKLM"
Key="SOFTWARE\Microsoft\PowerShell\ShellIds\Microsoft.PowerShell"
Name="Path" />
</Property>
<Condition Message="This application requires Windows PowerShell.">
<![CDATA[Installed OR POWERSHELLEXE]]>
</Condition>
</Fragment>
</Wix>
以及我的相关部分 product.wxs:
<!-- Execute Custom Action -->
<InstallExecuteSequence>
<Custom Action="RunPowerShellScript_set" After="InstallFiles" />
<Custom Action="RunPowerShellScript" After="InstallFiles">
<![CDATA[NOT Installed]]>
</Custom>
</InstallExecuteSequence>
我认为您的 Property="install_service.ps1"
不正确。尝试遵循 my blog post 中的模式。我希望它对你有帮助,刚刚再次测试了我的脚本并且它有效。祝你有美好的一天!
Wix 新手,但正在努力学习!
我正在使用 heat 生成一个 'directory.wxs' 文件,其中包含我的应用程序所需的所有文件。其中一个文件是 Powershell 脚本,我需要 运行 作为自定义操作。我正在尝试使用 -suid
标志,以便 File Id
在 运行 中保持一致。我不喜欢这个解决方案,因为如果我有两个同名的文件,我可能会遇到麻烦...欢迎对那个提出建议。
在 customaction.wxs 文件中,我尝试使用生成的 "install-service-filebeat.ps1" 作为自定义操作中的 属性 值。我在这里和其他网站上看过很多与此类似的示例/问题。我可能只是个白痴,遗漏了一些东西,但想知道我的问题是从我的 directory.wxs 文件中引用 ID,还是在我的语法中的其他地方。
以下是我的脚本,因为它们很长,所以我把它们放在了最后。
提前致谢!
我的 PS 脚本:
## Powershell Script to Create MSI ##
## Variables ##
# WIX Source Dir #
$WIX_DIR="C:\Program Files (x86)\WiX Toolset v3.11\bin"
# Source Dir for files to be enumerated into MSI #
$SRC_DIR="C:\application-directory"
# Name of our Application #
$APP_NAME="Filebeat"
# Where to stage the various .wxs files #
$STG_DIR="C:\wix-project${APP_NAME}\stage"
# Where to deliver the Final Product #
$TGT_DIR="C:\wix-project${APP_NAME}\output"
## Create MSI ##
# Compile the source files into a Fragment to be referenced by main builder Product.wxs #
& ${WIX_DIR}\heat.exe dir $SRC_DIR -srd -dr INSTALLDIR -cg MainComponentGroup -out ${STG_DIR}\directory.wxs -ke -sfrag -gg -ssuid -var var.SourceDir -sreg -scom
# Convert the .wxs files into .wxobj for consumption by light.exe #
& ${WIX_DIR}\candle.exe -dSourceDir="${SRC_DIR}" ${STG_DIR}\*.wxs -o ${STG_DIR}\ -ext WixUtilExtension -arch x64
# Create the final MSI package --CURRENTLY REFERENCING THE FILES EXPLICITY. NEED TO FIND WAY TO WILDCARD! #
& ${WIX_DIR}\light.exe -o ${TGT_DIR}${APP_NAME}_installer.msi ${STG_DIR}\customaction.wixobj ${STG_DIR}\directory.wixobj ${STG_DIR}\product.wixobj -cultures:en-US -ext WixUIExtension.dll -ext WiXUtilExtension.dll
这很好地生成了我的文件,并编译了它们。我的内容customaction.wxs:
<?xml version='1.0' encoding='windows-1252'?>
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>
<Fragment>
<!--Define the CustomAction for running the PowerShell script-->
<CustomAction Id="RunPowerShellScript_set"
Property="install_service.ps1"
Value=""[\[]POWERSHELLEXE[\]]" -Version 2.0 -NoProfile -NonInteractive -InputFormat None -ExecutionPolicy Bypass -Command "&'4(var.SourceDir)\[\[]#install_service.ps1[\]]'; exit $$($Error.Count)"" />
<CustomAction Id="RunPowerShellScript"
BinaryKey="WixCA"
DllEntry="CAQuietExec"
Execute="deferred"
Return="check"
Impersonate="yes" />
<!-- Ensure PowerShell is installed and obtain the PowerShell executable location -->
<Property Id="POWERSHELLEXE">
<RegistrySearch Id="POWERSHELLEXE"
Type="raw"
Root="HKLM"
Key="SOFTWARE\Microsoft\PowerShell\ShellIds\Microsoft.PowerShell"
Name="Path" />
</Property>
<Condition Message="This application requires Windows PowerShell.">
<![CDATA[Installed OR POWERSHELLEXE]]>
</Condition>
</Fragment>
</Wix>
以及我的相关部分 product.wxs:
<!-- Execute Custom Action -->
<InstallExecuteSequence>
<Custom Action="RunPowerShellScript_set" After="InstallFiles" />
<Custom Action="RunPowerShellScript" After="InstallFiles">
<![CDATA[NOT Installed]]>
</Custom>
</InstallExecuteSequence>
我认为您的 Property="install_service.ps1"
不正确。尝试遵循 my blog post 中的模式。我希望它对你有帮助,刚刚再次测试了我的脚本并且它有效。祝你有美好的一天!