在SharpSetup WIX中安装我的表单应用程序之前检查并安装.net 4.0

时间:2013-08-24 00:04:33

标签: .net wix

我没有太多(这是我的第一次)使用WIX的经验,所以我决定在VS 2012中使用SharpSetup模板来快速启动和运行。现在我的问题是我需要在用户机器上安装.net才能使用该应用程序,但我在这里找到的所有答案都谈到了使用'链'。我再一次不知道我在哪里。我假设.net安装程序我放入了与我的.exe相同的文件夹中,但此刻我正在摆动任何东西。您可以通过将.net安装程序exe包含在与我的项目相同的组中来尝试并尝试解决此问题。如果有人能解释我在代码中实现这个.net check / install的位置,我会非常感激!

这是我的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 个答案:

答案 0 :(得分:1)

您可以通过使用light链接到NetFxExtension来检查.NET框架是否已安装。只需将PropertyRef添加到您想要的那个。您可以找到这些属性的列表here

假设您要确保在安装软件之前存在.NET framework 4.0 Full,您可以在源代码中的某处添加:

<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

相关问题