0

我对 WIX 没有很多(这是我的第一次尝试)经验,所以我决定使用 VS 2012 中的 SharpSetup 模板来快速启动和运行它。现在我的问题是我需要在用户机器上安装 .net 以便他们使用该应用程序,但我在这里找到的所有答案都是关于使用“链”。再说一次,我不知道我会在哪里,但这个。我假设我将 .net 安装程序放在与我的 .exe 相同的文件夹中,但我现在正在摇摆不定。您可以看到我尝试通过将 .net 安装程序 exe 包含在与我的项目相同的组中来解决此问题,但失败了。如果有人可以解释我在代码中的哪个位置实现了这个 .net 检查/安装,我将不胜感激!

这是我的 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>
4

1 回答 1

1

您可以通过使用灯光链接到 NetFxExtension 来检查是否安装了 .NET 框架。只需添加一个PropertyRef到你想要的。您可以在此处找到这些属性的列表。

假设您想在安装软件之前确保 .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,一个用于您的捆绑包(这是您听说过的链)。这里有一个关于如何做到这一点的教程。

<Bundle>

    ...

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

您还必须在此处链接 NetFxExtension。此处列出了可能的 .NET 包列表。

于 2013-08-24T01:11:33.450 回答