环境:Windows 7(x64),WiX工具集3.10
我为一系列" WixUI_Mondo"做了一个额外的窗口,以创建一个用户可以安装IIS角色和.NET Framework 3.5功能的窗口......即使环境需要包含OS媒体SxS包。 (我知道不建议使用VbScriptCall,但BrowseDlg在我的环境中不能正常运行......在此阶段可能无法使用.NET代码。):
1)我的代码可以调用CustomAction并打开BrowseForFolder,但是它的返回值与SXS_PATH属性或SourcePathEdit文本框不同步,有什么问题?
片段如下:
<?xml version='1.0' encoding='utf-8'?>
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>
<Fragment>
<CustomAction Id="FolderExplorer" BinaryKey="FolderExplorer.vb" Impersonate="yes" Return="check" Execute="immediate" VBScriptCall="GetSxsPath" />
<Binary Id="FolderExplorer.vb" SourceFile="OpenVbScriptFolderExplorer.vbs"/>
<Property Id="ONOFF_PROPERTY" Secure="yes" Value="0" />
<Property Id="SXS_PATH" Value="C:\" />
<UI>
<Dialog Id="WindowsServerRolesAndFeaturesDlg"
Width="370" Height="270"
Title="[ProductName] [Setup]" NoMinimize="yes">
<Control Id="RdxOnlineOffline" Type="RadioButtonGroup" X="40" Y="63" Width="200" Height="35" Property="ONOFF_PROPERTY" Text="Choose install method:">
<RadioButtonGroup Property="ONOFF_PROPERTY">
<RadioButton Value="0" X="0" Y="0" Width="300" Height="15" Text="local package or online windows update available" />
<RadioButton Value="1" X="0" Y="20" Width="300" Height="15" Text="Require offline install from a media" />
</RadioButtonGroup>
</Control>
<Control Id="SourcePath" Type="Text"
X="45" Y="98" Width="200" Height="15"
TabSkip="no" Text="Input Sxs path when offline(&U):" />
<Control Id="SourcePathEdit" Type="Edit"
X="45" Y="110" Width="220" Height="18"
Property="SXS_PATH" Text="{80}">
<Condition Action="disable"><![CDATA[ONOFF_PROPERTY <> "1"]]></Condition>
<Condition Action="enable"><![CDATA[ONOFF_PROPERTY = "1"]]></Condition>
</Control>
<Control Id="SourcePathButton" Type="PushButton"
X="265" Y="110" Width="56" Height="18"
Default="yes" Text="Refer..">
<Condition Action="disable"><![CDATA[ONOFF_PROPERTY <> "1"]]></Condition>
<Condition Action="enable"><![CDATA[ONOFF_PROPERTY = "1"]]></Condition>
<Publish Event="DoAction" Value="FolderExplorer">1</Publish>
</Control>
<Control Id="Back" Type="PushButton"
X="180" Y="243" Width="56" Height="17"
Text="Back(&B)">
<Publish Event="NewDialog" Value="LicenseAgreementDlg">1</Publish>
</Control>
<Control Id="Next" Type="PushButton"
X="236" Y="243" Width="56" Height="17"
Default="yes" Text="次へ(&N)">
<!--<Publish Event="SpawnWaitDialog" Value="WaitForCostingDlg">CostingComplete = 1</Publish>-->
<Publish Event="NewDialog" Value="SetupTypeDlg">ProductID</Publish>
</Control>
<Control Id="Cancel" Type="PushButton"
X="304" Y="243" Width="56" Height="17"
Cancel="yes" Text="Cancel">
<Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
</Control>
<Control Id="BannerBitmap" Type="Bitmap"
X="0" Y="0" Width="370" Height="44"
TabSkip="no" Text="WixUI_Bmp_Banner" />
<Control Id="Description" Type="Text"
X="25" Y="23" Width="280" Height="15"
Transparent="yes" NoPrefix="yes">
<Text>Install Windows IIS role and .NET Framework features</Text>
</Control>
<Control Id="BottomLine" Type="Line"
X="0" Y="234" Width="370" Height="0" />
<Control Id="Title" Type="Text"
X="15" Y="6" Width="200" Height="15"
Transparent="yes" NoPrefix="yes">
<Text>{\WixUI_Font_Title}Set IIS role and .NET Framework 3.5 features</Text>
</Control>
<Control Id="BannerLine" Type="Line"
X="0" Y="44" Width="370" Height="0" />
</Dialog>
</UI>
</Fragment>
</Wix>
VBScript如下:
Option Explicit
public sub GetSxsPath()
Dim objShell
Dim objFolder
Dim objFolderItem
Dim strPath
Const WINDOW_HANDLE = 0
Const NO_OPTIONS = 0
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder _
(WINDOW_HANDLE, "Choose SxS Folder for IIS role and .NET features", NO_OPTIONS)
Set objFolderItem = objFolder.Self
strPath = objFolderItem.Path
MsgBox(strPath)
if Err.Number = 0 then
Session.Property("SXS_PATH") = strPath
end if
exit sub
end sub
2)如果1)成功,我想使用另一个自定义动作来调用DOS命令DISM,并设置SXS_PATH。有什么想法吗?
@echo off
SET SXS_PATH=D:\sources\sxs ←here insert the path 1)SourcePathEdit value...
DISM /Online /Enable-Feature /FeatureName:NetFx3 /All /Source:%SXS_PATH%
DISM /Online /Enable-Feature /FeatureName:IIS-WebServerRole /FeatureName:IIS-RequestFiltering /FeatureName:IIS-Security /FeatureName:IIS-HttpLogging /FeatureName:IIS-HealthAndDiagnostics /FeatureName:IIS-WebServerManagementTools /FeatureName:IIS-ManagementConsole /FeatureName:IIS-IIS6ManagementCompatibility /FeatureName:IIS-Metabase /FeatureName:IIS-WebServer /FeatureName:IIS-Performance /FeatureName:IIS-HttpCompressionStatic /FeatureName:IIS-CommonHttpFeatures /FeatureName:IIS-StaticContent /FeatureName:IIS-DefaultDocument /FeatureName:IIS-DirectoryBrowsing /FeatureName:IIS-HttpErrors /FeatureName:IIS-ApplicationDevelopment /FeatureName:IIS-ASPNET /FeatureName:IIS-NetFxExtensibility /FeatureName:IIS-ISAPIExtensions /FeatureName:IIS-ISAPIFilter /all /Source:%SXS_PATH%
答案 0 :(得分:0)
这是自我回复:
这不是&#34; CustomAction&#34;的正确答案,但至少我找到了我想要的解决方案:将资源管理器选择值设置为WiX编辑框。 (阅读文章Use WiX browser dialog to set edit box value和GitHub示例https://github.com/misohena/simple_wix_template)
如果目录标签设置(&#34; SxSFolder&#34;条目(D))不存在且属性(值(B)和属性引用),我的安装程序似乎呻吟错误代码2343 (A)(C))
我还在学习CustomAction来调用DOS DISM命令: 谢谢你:
以下是一个长期但有效的样本:
Main.wxs
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Name="FugaFuga 1.12.0" Id="MY-UID" UpgradeCode="MY-UID" Language="1041" Codepage="932" Version="1.12.0" Manufacturer="HogeHoge">
<Package Id="*" Keywords="Installer" Description="FugaFuga 1.12.0 Installer" Comments="FugaFuga is trademark of HogeHoge Inc." Manufacturer="HogeHoge" InstallerVersion="100" Languages="1041" Compressed="yes" SummaryCodepage="932" />
<Media Id="1" Cabinet="Sample.cab" EmbedCab="yes" DiskPrompt="CD-ROM 1" />
<Property Id="DiskPrompt" Value="HogeHoge FugaFuga 1.12.0 Installer [1]" />
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR" />
<Property Id="SXS_PATH" Secure="yes" Value="SxSFolder" /><!--(C)-->
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder" Name="PFiles">
<Directory Id="FugaFuga" Name="FugaFuga">
<Directory Id="INSTALLDIR" Name="Hoge 1.0">
<Component Id="FugaFugaLibrary" Guid="MY-UID">
<File Id="test.bat" Name="test.bat" DiskId="1" Source="test.bat" KeyPath="yes" />
</Component>
</Directory>
</Directory>
</Directory>
<Directory Id="ProgramMenuFolder" Name="Programs">
</Directory>
<Directory Id="SxSFolder" Name="SxS" /><!--(D)-->
<Directory Id="DesktopFolder" Name="Desktop" />
</Directory>
<Feature Id="Complete" Title="FugaFuga 1.12.0" Description="Complete Package" Display="expand" Level="1" ConfigurableDirectory="INSTALLDIR">
<Feature Id="MainProgram" Title="Program" Description="Main Program" Level="1">
<ComponentRef Id="FugaFugaLibrary" />
</Feature>
</Feature>
<UI Id="MyWixUI_Mondo">
<UIRef Id="WixUI_Mondo" />
<DialogRef Id="WindowsServerRolesAndFeaturesDlg" />
<Publish Dialog="LicenseAgreementDlg" Control="Next" Event="NewDialog" Value="WindowsServerRolesAndFeaturesDlg" Order="2">
LicenseAccepted = "1"
</Publish>
<Publish Dialog="SetupTypeDlg" Control="Back" Event="NewDialog" Value="WindowsServerRolesAndFeaturesDlg">
1
</Publish>
<Publish Dialog="WindowsServerRolesAndFeaturesDlg" Control="Back" Event="NewDialog" Value="LicenseAgreementDlg">LicenseAccepted = "1"</Publish>
<Publish Dialog="WindowsServerRolesAndFeaturesDlg" Control="Next" Event="SetTargetPath" Value="[SXS_PATH]" Order="2">1</Publish>
<Publish Dialog="WindowsServerRolesAndFeaturesDlg" Control="ChangeFolder" Property="_BrowseProperty" Value="[SXS_PATH]" Order="1">1</Publish><!--(B)-->
<Publish Dialog="WindowsServerRolesAndFeaturesDlg" Control="ChangeFolder" Event="SpawnDialog" Value="BrowseDlg" Order="2">1</Publish>
</UI>
<UIRef Id="WixUI_ErrorProgressText" />
</Product>
</Wix>
WindowsServerRolesAndFeaturesDlg.wxs
<?xml version='1.0' encoding='utf-8'?>
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>
<Fragment>
<Property Id="ONOFF_PROPERTY" Secure="yes" Value="0" />
<UI>
<Dialog Id="WindowsServerRolesAndFeaturesDlg"
Width="370" Height="270"
Title="[ProductName] [Setup]" NoMinimize="yes">
<Control Id="RdxOnlineOffline" Type="RadioButtonGroup" X="40" Y="63" Width="200" Height="35" Property="ONOFF_PROPERTY" Text="Choose install method:">
<RadioButtonGroup Property="ONOFF_PROPERTY">
<RadioButton Value="0" X="0" Y="0" Width="300" Height="15" Text="local package or online windows update available" />
<RadioButton Value="1" X="0" Y="20" Width="300" Height="15" Text="Require offline install from a media" />
</RadioButtonGroup>
</Control>
<Control Id="SourcePath" Type="Text"
X="45" Y="98" Width="200" Height="15"
TabSkip="no" Text="Input Sxs path when offline(&U)(&U):" />
<Control Type="PathEdit" Id="TxtDir" X="45" Y="110" Width="220" Height="18" Property="SXS_PATH" Indirect="yes"><!--(A)-->
<Condition Action="disable"><![CDATA[ONOFF_PROPERTY <> "1"]]></Condition>
<Condition Action="enable"><![CDATA[ONOFF_PROPERTY = "1"]]></Condition>
</Control>
<Control Id="ChangeFolder" Type="PushButton" X="265" Y="110" Width="56" Height="18" Text="Browse...">
<Condition Action="disable"><![CDATA[ONOFF_PROPERTY <> "1"]]></Condition>
<Condition Action="enable"><![CDATA[ONOFF_PROPERTY = "1"]]></Condition>
</Control>
<Control Id="Back" Type="PushButton"
X="180" Y="243" Width="56" Height="17"
Text="Back(&B)">
<Publish Event="NewDialog" Value="LicenseAgreementDlg">1</Publish>
</Control>
<Control Id="Next" Type="PushButton"
X="236" Y="243" Width="56" Height="17"
Default="yes" Text="Next(&N)">
<!--<Publish Event="SpawnWaitDialog" Value="WaitForCostingDlg">CostingComplete = 1</Publish>-->
<Publish Event="NewDialog" Value="SetupTypeDlg">ProductID</Publish>
</Control>
<Control Id="Cancel" Type="PushButton"
X="304" Y="243" Width="56" Height="17"
Cancel="yes" Text="Cancel">
<Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
</Control>
<Control Id="BannerBitmap" Type="Bitmap"
X="0" Y="0" Width="370" Height="44"
TabSkip="no" Text="WixUI_Bmp_Banner" />
<Control Id="Description" Type="Text"
X="25" Y="23" Width="280" Height="15"
Transparent="yes" NoPrefix="yes">
<Text>Install Windows IIS role and .NET Framework features</Text>
</Control>
<Control Id="BottomLine" Type="Line"
X="0" Y="234" Width="370" Height="0" />
<Control Id="Title" Type="Text"
X="15" Y="6" Width="200" Height="15"
Transparent="yes" NoPrefix="yes">
<Text>{\WixUI_Font_Title}Set IIS role and .NET Framework 3.5 features</Text>
</Control>
<Control Id="BannerLine" Type="Line"
X="0" Y="44" Width="370" Height="0" />
</Dialog>
</UI>
</Fragment>
</Wix>