2011-06-10 296 views
0

我需要在LaunchConditions之前檢查Framework版本,操作系統版本&管理員權限。我的操作系統版本&管理條件按預期工作,但不是框架版本。 NETFRAMEWORK35沒有被填充。以下是我的代碼。LaunchConditions之前的自定義操作

<PropertyRef Id="NETFRAMEWORK35" /> 
<UI> 
    <UIRef Id='...'/> 
    <Error Id="2001">Please uninstall older version of this product to continue.</Error> 
    <Error Id="2002">This application is only supported on Windows Server 2008(64 bit) or Windows 2003(32 or 64 bit).</Error> 
    <Error Id="2003">Microsoft .NET Framework Version 3.5 is missing. To download please visit $(var.FrameworkDownload)</Error> 
    <Error Id="2004">You need to be an administrator to install this product.</Error> 

</UI> 

<CustomAction Id="CurrentVersionDetected" Error="2001"/> 
<CustomAction Id="WrongOSVersionDetected" Error="2002" /> 
<CustomAction Id="FrameworkMissing" Property="NETFRAMEWORK35" Error="2003" /> 
<CustomAction Id="IsNotAdministrator" Error="2004" /> 

<InstallExecuteSequence> 
    <Custom Action="IsNotAdministrator" After="FrameworkMissing"> 
    <![CDATA[NOT(Installed OR Privileged)]]> 
    </Custom> 
    <Custom Action="FrameworkMissing" After="WrongOSVersionDetected"> 
    **<![CDATA[NETFRAMEWORK35]]> //This is make sure it is getting fired, but not** 
    </Custom> 
    <Custom Action="WrongOSVersionDetected" After="FindRelatedProducts"> 
    <![CDATA[NOT(Installed OR VersionNT = 601 OR (VersionNT = 600 AND VersionNT64))]]> 
    </Custom> 
    <Custom Action="CurrentVersionDetected" After="AppSearch">SELFFOUND</Custom> 
</InstallExecuteSequence> 

<InstallUISequence> 
    <Custom Action="IsNotAdministrator" After="FrameworkMissing"> 
    <![CDATA[NOT(Installed OR Privileged)]]> 
    </Custom> 
    <Custom Action="FrameworkMissing" After="WrongOSVersionDetected"> 
    **<![CDATA[NETFRAMEWORK35]]> //This is make sure it is getting fired, but not** 
    </Custom> 
    <Custom Action="WrongOSVersionDetected" After="FindRelatedProducts"> 
    <![CDATA[NOT(Installed OR VersionNT = 601 OR (VersionNT = 600 AND VersionNT64))]]> 
    </Custom> 
    <Custom Action="CurrentVersionDetected" After="AppSearch">SELFFOUND</Custom> 
</InstallUISequence> 


But strangely same action work if i put it after InstallValidate 

<Custom Action="FrameworkMissing" After="InstallValidate"> 
    **<![CDATA[NETFRAMEWORK35]]> //This is fired** 
</Custom> 

回答

0

假設你正在使用的WiX的NETFX NETFRAMEWORK35屬性,您需要AppSearch,這是處理RegistrySearch的標準動作後安排FrameworkMissing。

+0

謝謝,我正在使用NetFx屬性。但有沒有辦法在AppSearch之前做到這一點?這是要求,即使在啓動屏幕之前? – Suresh 2011-06-10 11:47:13

+0

@Suresh:沒有.AppSearch是什麼設置屬性。但LaunchConditions出現在AppSearch之後,所以沒有問題......? – 2011-06-10 12:04:24

+0

問題是啓動屏幕顯示,任何錯誤都顯示爲對話框(如子窗口)。但是,如果你看我的代碼進行操作系統版本檢查,管理員檢查啓動屏幕將永遠不會顯示。當你點擊msi時,它只是一個錯誤窗口並停止。我正在嘗試爲框架版本獲得類似的行爲。我清楚了嗎? – Suresh 2011-06-10 12:46:37

0

在product.wxs中使用此代碼來檢查需求框架。

<Condition Message= 
     'This setup requires the .NET Framework 2.0 or higher. Please install .NET Framework 2.0 or higher and run the setup again.'> 
     <![CDATA[MsiNetAssemblySupport >= "2.0.50727"]]> 
    </Condition> 

這裏我正在檢查.net framework 2.0。同樣,您可以更改條件來檢查其他版本