如何安装.NET Framework 4.0作为安装的一部分?

Ole*_*leg 7 .net installer frameworks wix

我创建了bootstrapper,它可以工作,但它不安装.NET Framework 4.0.安装完成后,我的应用程序无法启动,因为没有.NET Framework 4.0.为什么不安装NETF 4.0?

<ItemGroup>
    <BootstrapperFile Include="Microsoft.Windows.Installer.4.5">
      <ProductName>Windows Installer 4.5</ProductName>
    </BootstrapperFile>
       <BootstrapperPackage Include=".NETFramework,Version=v4.0">
            <Visible>True</Visible>
            <ProductName>.NET Framework 4.0</ProductName>
            <Install>True</Install>
        <Visible>True</Visible>
      </BootstrapperPackage>
  </ItemGroup>
  <Import Project="$(WixTargetsPath)" />
  <Target Name="AfterBuild">
    <GenerateBootstrapper ApplicationFile="DOGInstaller.msi" 
    ApplicationName="DOG" 
    BootstrapperItems="@(BootstrapperFile)" 
    CopyComponents="True" 
    ComponentsLocation="HomeSite"
    OutputPath="$(OutputPath)\en-us\"
    Path="C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bootstrapper" 
    Culture="en" />
  </Target>
Run Code Online (Sandbox Code Playgroud)

Han*_*ood 5

在wixproj文件中,添加以下结构.请注意,<WixTargetsPath>标记必须与第一个<PropertyGroup>节点中的其余部分一起存在.

<Project>
  <PropertyGroup> <!-- This must be the first PropertyGroup node. -->
    ...
    <WixTargetsPath Condition=" '$(WixTargetsPath)' == '' AND '$(MSBuildExtensionsPath32)' != '' ">$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
    <WixTargetsPath Condition=" '$(WixTargetsPath)' == '' ">$(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
  </PropertyGroup>
  ...
  <ItemGroup>
    <BootstrapperFile Include="Microsoft.Windows.Installer.3.1">
      <ProductName>Windows Installer 3.1</ProductName>
    </BootstrapperFile>
    <BootstrapperFile Include=".NETFramework,Version=v4.0">
      <ProductName>Microsoft .NET Framework 4.0 (x86 and x64)</ProductName>
    </BootstrapperFile>
  </ItemGroup>
  <PropertyGroup>
    <BootstrapperPath>$(ProgramFiles)\Microsoft SDKs\Windows\v7.0A\Bootstrapper\</BootstrapperPath>
  </PropertyGroup>
  <Target Name="AfterBuild">
    <GenerateBootstrapper
      ApplicationFile="$(TargetFileName)"
      ApplicationName="$(OutputName)"
      BootstrapperItems="@(BootstrapperFile)"
      ComponentsLocation="Relative"
      CopyComponents="True"
      OutputPath="$(OutputPath)"
      Path="$(BootstrapperPath)" />
  </Target>
</Product>
Run Code Online (Sandbox Code Playgroud)


Sun*_*wal 0

我使用dotnetinstaller来检查和安装先决条件。它非常简单且易于使用。它还提供将 msi 转换为 exe 并附加 UAC 提示符的功能。你需要有一个配置文件

然后在您的项目中的构建后事件中添加此代码。这将嵌入您的 msi 和先决条件文件。

copy /Y "$(ProjectDir)Files\dotnetfx35setup.exe" "C:\Windows\Temp"
copy /Y $(TargetPath) "C:\Windows\Temp"
"$(SolutionDir)Tools\dotNetInstaller 2.0\Bin\installerLinker.exe" /o:"$(TargetDir)Setup.exe" /t:"$(SolutionDir)Tools\dotNetInstaller 2.0\Bin\dotNetInstaller.exe" /c:"$(ProjectDir)Files\Configuration.xml" /b:"$(ProjectDir)Files\banner.bmp" /Embed+ /Verbose+
Run Code Online (Sandbox Code Playgroud)