2013-08-24 22 views
0

我沒有太多(這是我的第一次嘗試)WIX的經驗,所以我決定在VS 2012中使用SharpSetup模板快速啓動並運行。現在我的問題是我需要在用戶機器上安裝.net以使用該應用程序,但是我在這裏找到的所有答案都是關於使用「鏈」的。再一次,我不知道我會在哪裏,但這個。我假設我安裝的.net安裝程序位於與我的.exe相同的文件夾中,但此時我正在擺動任何內容。您可以看到我嘗試過,並且通過將.net安裝程序exe包含在與我的項目相同的組中,從而解決了此問題。如果有人可以解釋代碼中的位置,我實現這個.net檢查/安裝我非常感謝!在SharpSetup中安裝我的表單應用程序之前檢查和安裝.net 4.0 WIX

這裏是我的維克斯:

<?xml version="1.0" encoding="UTF-8"?> 
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> 
<?include Product.Defines.wxi ?> 



<Fragment> 
<Directory Id="TARGETDIR" Name="SourceDir"> 
    <Directory Id="ProgramMenuFolder" Name="Programs"> 
    <Directory Id="ProgramMenuDir" Name="!(loc.APPNAME)"> 
     <Component Id="pmd" Guid="{9d848b50-cab5-4f96-abe3-4c551c7335db}"> 
     <RegistryValue Root="HKCU" Key="SOFTWARE\$(var.AppCode)\ProgramMenuDir" Type="string" Value="ProgramMenuDir" KeyPath="yes" /> 
     <RemoveFolder Id="ProgramMenuDirRF" On="uninstall" /> 
     </Component> 
    </Directory> 
    </Directory> 
    <Directory Id="DesktopFolder" Name="Desktop" /> 
    <Directory Id="StartupFolder" Name="Startup" /> 
    <Directory Id="ProgramFilesFolder"> 
    <Directory Id="INSTALLLOCATION" Name="$(var.AppCode)"> 
     <Component Id="MainExecutable" Guid="{bbd95e2b-9f33-4c67-80d9-9b80f3f52001}"> 
     <File Id="MainExecutableFile" Name="SampleApp.exe" Source="..\ProductBuild\sampleFile.txt" KeyPath="yes"> 
      <Shortcut Id="MainExecutableStartMenu" Directory="ProgramMenuDir" Name="!(loc.APPNAME)" WorkingDirectory="INSTALLDIR" Icon="icon.ico" IconIndex="0" Advertise="yes"/> 
      <Shortcut Id="MainExecutableDesktop" Directory="DesktopFolder" Name="!(loc.APPNAME)" WorkingDirectory="INSTALLDIR" Icon="icon.ico" IconIndex="0" Advertise="yes" /> 
     </File> 
     </Component> 
     <Component Id="SubFeatureExecutable" Guid="{0b30137e-621e-49a1-83bb-d0b50c3834b8}"> 
     <File Id="SubFeatureExecutableFile" Name="SampleLibrary.dll" Source="..\ProductBuild\sampleFile.txt" Vital="yes" /> 
     </Component> 
     <Component Id="DocumentationPound" Guid="{006f5e3e-bb68-409c-8c30-37dc82a0a3f9}"> 
     <File Id="DocumentationPoundFile" Name="Pound.currency" Source="..\ProductBuild\sampleFile.txt" Vital="yes" /> 
     </Component> 
     <Component Id="DocumentationEuro" Guid="{a1e06fa0-0293-4314-ad3b-5a82b7cde17e}"> 
     <File Id="DocumentationEuroFile" Name="Euro.currency" Source="..\ProductBuild\sampleFile.txt" Vital="yes" /> 
     </Component> 
     <Component Id="DocumentationCommon" Guid="{578635b1-b912-428e-b161-3507465bced9}"> 
     <File Id="DocumentationCommonFile" Name="help.exe" Source="..\ProductBuild\sampleFile.txt" Vital="yes" /> 
     </Component> 
     <Component Id="DocumentationEnglish" Guid="{434f103e-7be8-49ac-b90b-9675f42e6caa}"> 
     <File Id="DocumentationEnglishFile" Name="English.documentation" Source="..\ProductBuild\sampleFile.txt" Vital="yes" /> 
     </Component> 
     <Component Id="DocumentationFrench" Guid="{bd132536-94c6-488d-aa8a-700d4070718f}"> 
     <File Id="DocumentationFrenchFile" Name="French.documentation" Source="..\ProductBuild\sampleFile.txt" Vital="yes" /> 
     </Component> 
     <Component Id="DocumentationGerman" Guid="{045e065e-bc43-418d-97fc-701b0d80dca3}"> 
     <File Id="DocumentationGermanFile" Name="German.documentation" Source="..\ProductBuild\sampleFile.txt" Vital="yes" /> 
     </Component> 
    </Directory> 
    </Directory> 
</Directory> 
<DirectoryRef Id="INSTALLLOCATION"> 
    <Component Id="dotNetFx40_Full_x86_x64.exe" Guid="{c5e5282e-dafe-4e51-857f-2648bbcb743c}"> 
    <File Id="fil8a9sd8fa9s8df9a8fs98fd9sfa908sdf" KeyPath="yes" Source="..\ProductBuild\dotNetFx40_Full_x86_x64.exe" /> 
    </Component> 
    <Component Id="EntityFramework.dll" Guid="{C8010F46-05CF-4D73-8F69-6F68176EC558}"> 
    <File Id="fil34ECF92861B5C4F79E50A3EE293AC68A" KeyPath="yes" Source="..\ProductBuild\EntityFramework.dll" /> 
    </Component> 
    <Component Id="EntityFramework.xml" Guid="{C68D3DE4-D338-4C83-96F1-DCF7D1FA1AAC}"> 
    <File Id="fil04EFBF6DC1A33030A49CFCE8889F7E70" KeyPath="yes" Source="..\ProductBuild\EntityFramework.xml" /> 
    </Component> 
    <Component Id="PetesTimeTray.exe" Guid="{C1891D2B-9815-42A3-BCD7-3316F0F28AC7}"> 
    <File Id="fil7AC61C1EB5B94A1F447DA90D87BB454B" KeyPath="yes" Source="..\ProductBuild\PetesTimeTray.exe"> 
     <Shortcut Id="PetesTimeTrayStartMenu" Directory="ProgramMenuDir" Name="!(loc.APPNAME)" WorkingDirectory="INSTALLDIR" Icon="icon.ico" IconIndex="0" Advertise="yes" /> 
     <Shortcut Id="PetesTimeTrayDesktop" Directory="DesktopFolder" Name="!(loc.APPNAME)" WorkingDirectory="INSTALLDIR" Icon="icon.ico" IconIndex="0" Advertise="yes" /> 
     <Shortcut Id="PetesTimeTrayStartUp" Directory="StartupFolder" Name="!(loc.APPNAME)" WorkingDirectory="INSTALLDIR" Icon="icon.ico" IconIndex="0" Advertise="yes" /> 
    </File> 
    </Component> 
    <Component Id="PetesTimeTray.exe.config" Guid="{321EFADC-29DD-4E41-BED0-5B360FAEBBA0}"> 
    <File Id="fil1DC527512D4271328F383F45C1F9229B" KeyPath="yes" Source="..\ProductBuild\PetesTimeTray.exe.config" /> 
    </Component> 
</DirectoryRef> 
<ComponentGroup Id="PetesTimeTrayFiles"> 
    <ComponentRef Id="dotNetFx40_Full_x86_x64.exe" /> 
    <ComponentRef Id="EntityFramework.dll" /> 
    <ComponentRef Id="EntityFramework.xml" /> 
    <ComponentRef Id="PetesTimeTray.exe" /> 
    <ComponentRef Id="PetesTimeTray.exe.config" /> 
</ComponentGroup> 
</Fragment> 
</Wix> 

回答

1

如果.NET Framework是通過鏈接到NetFxExtension光安裝您可以檢查。只需添加一個PropertyRef到你想要的。您可以找到這些屬性的列表here

說你要確保.NET框架4.0完全存在,然後再安裝你的軟件,你會在源代碼中添加這個地方:

<PropertyRef Id="NETFRAMEWORK40FULL" /> 
<Condition Message=".NET Framework 4.0 Full is not installed."> 
    NETFRAMEWORK40FULL 
</Condition> 

當運行MSI,將LaunchConditions行動將運行並檢查是否設置了NETFRAMEWORK40FULL屬性。如果是,則繼續安裝,否則安裝失敗。

但是,如果您想事先安裝.NET Framework,則需要兩個WiX項目。一個用於基本的MSI,另一個用於捆綁(這是您聽到的鏈條)。有關於如何做到這一點的教程here

<Bundle> 

    ... 

    <Chain> 
     <PackageGroupRef Id="NetFx40Redist"/> 
     <MsiPackage Id="MyApplication" SourceFile="path to your msi"/> 
    </Chain> 
</Bundle> 

您也必須在此處鏈接NetFxExtension。列出了可能的.NET軟件包列表here

相關問題