2014-06-26 57 views
5

我有一個使用IIS的項目,我想用Wix爲它創建一個安裝程序。我已經成功創建了應用程序的.msi安裝程序,並且爲它創建了一個Bundle安裝程序,它將安裝必備軟件,然後安裝我的應用程序。Wix&Burn - 如果尚未安裝,請安裝IIS

這裏是捆綁代碼:

<?xml version="1.0" encoding="UTF-8"?> 
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" 
    xmlns:util="http://schemas.microsoft.com/wix/UtilExtension" 
    xmlns:bal="http://schemas.microsoft.com/wix/BalExtension"> 
    <Bundle Name="Bootstrapper" Version="1.0.0.0" Manufacturer="VilmosNagy" UpgradeCode="844c755f-f02b-4dd3-8b9c-af2498f3128c"> 
    <BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense" /> 
    <Chain> 
     <PackageGroupRef Id="NetFx45Web"/> 
     <PackageGroupRef Id="SQLServerExpress"/> 
     <!-- <MsiPackage SourceFile="path\to\your.msi" /> --> 
    </Chain> 
    </Bundle> 
</Wix> 

我的問題是,我怎麼能安裝(?或啓用)的IIS,如果沒有安裝?

謝謝!

回答

3

@Nagy維爾莫什,您的解決方案將不會在64位操作系統上運行。刻錄是32位程序。它將啓動32位「dism.exe」,即使您希望它通過在64位操作系統上提供完整路徑「C:\ Windows \ System32 \ dism.exe」來運行64位dism.exe。這是由「File System Redirector」造成的。

該dism的日誌會告訴你它是32位或64位。打開文件 「C:\ WINDOWS \日誌\ DISM \ dism.log」,你會發現這樣的信息:

Host machine information: OS Version=6.1.7600, Running architecture=x86

或者,

Host machine information: OS Version=6.1.7600, Running architecture=amd64

當您嘗試DISM上運行32位和64位操作系統,您將收到此錯誤

Error: 11 You cannot service a running 64-bit operating system with a 32-bit version of DI SM. Please use the version of DISM that corresponds to your computer's architecture. The DISM log file can be found at C:\Windows\Logs\DISM\dism.log

我的解決方案是創建另一個WiX的安裝項目「InstallPrerequisites」,並以「QtExec64CmdLine」運行64位DISM。以下是一個示例:

<!--1.You need to use the x64 version of quiet command line  
    2.[System64Folder] is also needed. If not, QtExec64CmdLine will find a 32-bit dism.exe to run. 
--> 
<Property Id="QtExec64CmdLine" Value='"[System64Folder]dism.exe" /Online /Apply-Unattend:[ProductTmpFolder]iis_unattend.xml'/> 
<CustomAction Id="SilentLaunch" BinaryKey="WixCA" DllEntry="CAQuietExec64" Execute="immediate" Return="check" /> 

我使用答案文件來包含所有功能,因此我們可以一次啓用它們。然後鏈安裝

<MsiPackage DisplayName="Install Prerequisites" SourceFile="$(var.InstallPrerequisites.TargetPath)" /> 

更新: 通過使用 「C:\ WINDOWS \ SysNative \ dism.exe」,我現在可以避免x64平臺的獨立項目。從日誌中可以看到,32位進程現在正在運行64位DISM。

2015-10-26 16:28:07, Info DISM DISM.EXE: <----- Starting Dism.exe session -----> 
2015-10-26 16:28:07, Info DISM DISM.EXE: 
2015-10-26 16:28:07, Info DISM DISM.EXE: Host machine information: OS Version=6.1.7601, Running architecture=amd64, Number of processors=4 
2015-10-26 16:28:07, Info DISM DISM.EXE: Executing command line: C:\windows\SysNative\dism.exe 
2015-10-26 16:28:07, Info DISM DISM Provider Store: PID=2000 Getting the collection of providers from a local provider store type. - CDISMProviderStore::GetProviderCollection 
.... 
2015-10-26 16:28:09, Info DISM DISM.EXE: Image session has been closed. Reboot required=no. 
2015-10-26 16:28:09, Info DISM DISM.EXE: 
2015-10-26 16:28:09, Info DISM DISM.EXE: <----- Ending Dism.exe session -----> 
+4

要使它在64位操作系統上工作,只需將DISM作爲解釋[這裏](http://stackoverflow.com/a/5936741/15186)以避免重定向。 –

+0

@omatrot它的工作原理,我已經更新了答案。謝謝! – Rader

2

請嘗試以下CustomAction代碼: -

<Property Id="INSTALLIISPROP" Value="C:\Windows\System32\dism.exe" /> 

    <CustomAction 
     Id="InstallIISCA" 
     Return="check" 
     Property="INSTALLIISPROP" 
     Execute="deferred" 
     HideTarget="yes" 
     Impersonate="yes" 
     ExeCommand="/Online /Enable-Feature /FeatureName:IIS-WebServerRole /FeatureName:IIS-WebServer /FeatureName:IIS-CommonHttpFeatures /FeatureName:IIS-StaticContent /FeatureName:IIS-DefaultDocument /FeatureName:IIS-DirectoryBrowsing /FeatureName:IIS-HttpErrors /FeatureName:IIS-HttpRedirect /FeatureName:IIS-ApplicationDevelopment /FeatureName:IIS-ASPNET /FeatureName:IIS-NetFxExtensibility /FeatureName:IIS-ASP /FeatureName:IIS-ISAPIExtensions /FeatureName:IIS-ISAPIFilter /FeatureName:IIS-HealthAndDiagnostics /FeatureName:IIS-HttpLogging /FeatureName:IIS-LoggingLibraries /FeatureName:IIS-RequestMonitor /FeatureName:IIS-HttpTracing /FeatureName:IIS-CustomLogging  /FeatureName:IIS-Security /FeatureName:IIS-WindowsAuthentication /FeatureName:IIS-RequestFiltering /FeatureName:IIS-IPSecurity /FeatureName:IIS-Performance /FeatureName:IIS-HttpCompressionStatic  /FeatureName:IIS-WebServerManagementTools /FeatureName:IIS-ManagementConsole /FeatureName:IIS-ManagementScriptingTools /FeatureName:IIS-ManagementService /FeatureName:WAS-WindowsActivationService /FeatureName:WAS-ProcessModel /FeatureName:WAS-NetFxEnvironment /FeatureName:WAS-ConfigurationAPI /FeatureName:NetFx3" /> 

    <InstallExecuteSequence> 
     <Custom Action="InstallIISCA" Before="InstallFinalize"> 
      <![CDATA[NOT Installed AND IISMAJORVERSION]]> 
     </Custom> 
    </InstallExecuteSequence> 
+0

我應該在哪裏把這個CustomAction代碼?鏈標籤內?要麼? –

+1

這需要在Product.Wxs文件中的產品標籤下。 –

+0

是的,但我想將IIS安裝程序放入刻錄包,而不是.msi文件。 (My Burn軟件包包含SQLExpress,.NET,IIS和我的項目的.msi安裝程序的安裝程序)。但是,感謝dism.exe文件及其命令,我想我解決了它的問題。 –

13

基於Harbinder Singhanswer,這裏是我的解決方案:

<?xml version="1.0" encoding="UTF-8"?> 
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" 
    xmlns:util="http://schemas.microsoft.com/wix/UtilExtension" 
    xmlns:bal="http://schemas.microsoft.com/wix/BalExtension"> 
    <Bundle Name="Bootstrapper" Version="1.0.0.0" Manufacturer="VilmosNagy" UpgradeCode="844c755f-f02b-4dd3-8b9c-af2498f3128c"> 
     <BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense" /> 

    <Chain> 
     <PackageGroupRef Id="InstallIIS"/> 
    </Chain> 
    </Bundle> 
    <Fragment>  
    <PackageGroup Id="InstallIIS"> 
     <ExePackage 
        Id="IIS_part0" 
        SourceFile="run.bat" 
        DisplayName="Installing IIS: IIS-WebServerRole" 
        InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-WebServerRole" 
        > 
     </ExePackage> 
     <ExePackage 
        Id="IIS_part1" 
        SourceFile="run.bat" 
        DisplayName="Installing IIS: IIS-WebServer" 
        InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-WebServer" 
        > 
     </ExePackage> 
     <ExePackage 
        Id="IIS_part2" 
        SourceFile="run.bat" 
        DisplayName="Installing IIS: IIS-CommonHttpFeatures" 
        InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-CommonHttpFeatures" 
        > 
     </ExePackage> 
     <ExePackage 
        Id="IIS_part3" 
        SourceFile="run.bat" 
        DisplayName="Installing IIS: IIS-StaticContent" 
        InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-StaticContent" 
        > 
     </ExePackage> 
     <ExePackage 
        Id="IIS_part4" 
        SourceFile="run.bat" 
        DisplayName="Installing IIS: IIS-DefaultDocument" 
        InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-DefaultDocument" 
        > 
     </ExePackage> 
     <ExePackage 
        Id="IIS_part5" 
        SourceFile="run.bat" 
        DisplayName="Installing IIS: IIS-DirectoryBrowsing" 
        InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-DirectoryBrowsing" 
        > 
     </ExePackage> 
     <ExePackage 
        Id="IIS_part6" 
        SourceFile="run.bat" 
        DisplayName="Installing IIS: IIS-HttpErrors" 
        InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-HttpErrors" 
        > 
     </ExePackage> 
     <ExePackage 
        Id="IIS_part7" 
        SourceFile="run.bat" 
        DisplayName="Installing IIS: IIS-HttpRedirect" 
        InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-HttpRedirect" 
        > 
     </ExePackage> 
     <ExePackage 
        Id="IIS_part8" 
        SourceFile="run.bat" 
        DisplayName="Installing IIS: IIS-ApplicationDevelopment" 
        InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-ApplicationDevelopment" 
        > 
     </ExePackage> 
     <ExePackage 
        Id="IIS_part10" 
        SourceFile="run.bat" 
        DisplayName="Installing IIS: IIS-NetFxExtensibility" 
        InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-NetFxExtensibility" 
        > 
     </ExePackage> 
     <ExePackage 
        Id="IIS_part12" 
        SourceFile="run.bat" 
        DisplayName="Installing IIS: IIS-ISAPIExtensions" 
        InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-ISAPIExtensions" 
        > 
     </ExePackage> 
     <ExePackage 
        Id="IIS_part11" 
        SourceFile="run.bat" 
        DisplayName="Installing IIS: IIS-ASP" 
        InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-ASP" 
        > 
     </ExePackage> 
     <ExePackage 
        Id="IIS_part13" 
        SourceFile="run.bat" 
        DisplayName="Installing IIS: IIS-ISAPIFilter" 
        InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-ISAPIFilter" 
        > 
     </ExePackage> 
     <ExePackage 
        Id="IIS_part9" 
        SourceFile="run.bat" 
        DisplayName="Installing IIS: IIS-ASPNET" 
        InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-ASPNET" 
        > 
     </ExePackage> 
     <ExePackage 
        Id="IIS_part14" 
        SourceFile="run.bat" 
        DisplayName="Installing IIS: IIS-HealthAndDiagnostics" 
        InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-HealthAndDiagnostics" 
        > 
     </ExePackage> 
     <ExePackage 
        Id="IIS_part15" 
        SourceFile="run.bat" 
        DisplayName="Installing IIS: IIS-HttpLogging" 
        InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-HttpLogging" 
        > 
     </ExePackage> 
     <ExePackage 
        Id="IIS_part16" 
        SourceFile="run.bat" 
        DisplayName="Installing IIS: IIS-LoggingLibraries" 
        InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-LoggingLibraries" 
        > 
     </ExePackage> 
     <ExePackage 
        Id="IIS_part17" 
        SourceFile="run.bat" 
        DisplayName="Installing IIS: IIS-RequestMonitor" 
        InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-RequestMonitor" 
        > 
     </ExePackage> 
     <ExePackage 
        Id="IIS_part18" 
        SourceFile="run.bat" 
        DisplayName="Installing IIS: IIS-HttpTracing" 
        InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-HttpTracing" 
        > 
     </ExePackage> 
     <ExePackage 
        Id="IIS_part19" 
        SourceFile="run.bat" 
        DisplayName="Installing IIS: IIS-CustomLogging" 
        InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-CustomLogging" 
        > 
     </ExePackage> 
     <ExePackage 
        Id="IIS_part20" 
        SourceFile="run.bat" 
        DisplayName="Installing IIS: IIS-Security" 
        InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-Security" 
        > 
     </ExePackage> 
     <ExePackage 
        Id="IIS_part21" 
        SourceFile="run.bat" 
        DisplayName="Installing IIS: IIS-WindowsAuthentication" 
        InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-WindowsAuthentication" 
        > 
     </ExePackage> 
     <ExePackage 
        Id="IIS_part22" 
        SourceFile="run.bat" 
        DisplayName="Installing IIS: IIS-RequestFiltering" 
        InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-RequestFiltering" 
        > 
     </ExePackage> 
     <ExePackage 
        Id="IIS_part23" 
        SourceFile="run.bat" 
        DisplayName="Installing IIS: IIS-IPSecurity" 
        InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-IPSecurity" 
        > 
     </ExePackage> 
     <ExePackage 
        Id="IIS_part24" 
        SourceFile="run.bat" 
        DisplayName="Installing IIS: IIS-Performance" 
        InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-Performance" 
        > 
     </ExePackage> 
     <ExePackage 
        Id="IIS_part25" 
        SourceFile="run.bat" 
        DisplayName="Installing IIS: IIS-HttpCompressionStatic" 
        InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-HttpCompressionStatic" 
        > 
     </ExePackage> 
     <ExePackage 
        Id="IIS_part26" 
        SourceFile="run.bat" 
        DisplayName="Installing IIS: IIS-WebServerManagementTools" 
        InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-WebServerManagementTools" 
        > 
     </ExePackage> 
     <ExePackage 
        Id="IIS_part27" 
        SourceFile="run.bat" 
        DisplayName="Installing IIS: IIS-ManagementConsole" 
        InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-ManagementConsole" 
        > 
     </ExePackage> 
     <ExePackage 
        Id="IIS_part28" 
        SourceFile="run.bat" 
        DisplayName="Installing IIS: IIS-ManagementScriptingTools" 
        InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-ManagementScriptingTools" 
        > 
     </ExePackage> 
     <ExePackage 
        Id="IIS_part29" 
        SourceFile="run.bat" 
        DisplayName="Installing IIS: IIS-ManagementService" 
        InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:IIS-ManagementService" 
        > 
     </ExePackage> 
     <ExePackage 
        Id="IIS_part30" 
        SourceFile="run.bat" 
        DisplayName="Installing IIS: WAS-WindowsActivationService" 
        InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:WAS-WindowsActivationService" 
        > 
     </ExePackage> 
     <ExePackage 
        Id="IIS_part31" 
        SourceFile="run.bat" 
        DisplayName="Installing IIS: WAS-ProcessModel" 
        InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:WAS-ProcessModel" 
        > 
     </ExePackage> 
     <ExePackage 
        Id="IIS_part32" 
        SourceFile="run.bat" 
        DisplayName="Installing IIS: WAS-NetFxEnvironment" 
        InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:WAS-NetFxEnvironment" 
        > 
     </ExePackage> 
     <ExePackage 
        Id="IIS_part33" 
        SourceFile="run.bat" 
        DisplayName="Installing IIS: WAS-ConfigurationAPI" 
        InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:WAS-ConfigurationAPI" 
        > 
     </ExePackage> 
     <ExePackage 
        Id="IIS_part34" 
        SourceFile="run.bat" 
        DisplayName="Installing IIS: NetFx3" 
        InstallCommand="dism.exe /Online /Enable-Feature /FeatureName:NetFx3" 
        > 
     </ExePackage> 
    </PackageGroup> 
    </Fragment> 
</Wix> 

run.bat文件是一個簡單的文本文件,其中包含%*

此解決方案僅適用於Windows 7,或者更高,「造成dism.exe不是以前版本的Windows的一部分7.

+0

不知道是否有更好的方法,但對我來說,我必須用'C:\ WINDOWS \ SYSNATIVE \ DISM.EXE'替換'dism.exe'(似乎在使用32位本應該使用64位?可能我的引導程序沒有運行正確的版本? –

+0

我想你可以在這裏看到解釋:https://stackoverflow.com/a/26422001/2891426 –

0

這裏是速戰速決

run64一些WIX代碼。蝙蝠:我不知道爲什麼它需要兩條線來欺騙文件系統重定向

set "SystemPath=%windir%\Sysnative" 
CD "%windir%\Sysnative"" 
%* 

InstallIIS.wxs:更換爲run.bat中平臺特定批次

<?if $(var.Platform) = x86 ?> 
    <?define PlatformRunBatch = "run.bat" ?> 
    <?else?> 
    <?define PlatformRunBatch = "run64.bat" ?> 
    <?endif?> 
    <ExePackage Id="IIS_part0" 
       SourceFile="$(var.PlatformRunBatch)"