How to install redistributable package of .NET Fra

2019-05-26 04:52发布

问题:

I have a general task: install .NET Framework 3.5 during the setup of my product.

I do the following:

  1. I have created a custom action X
  2. Custom action X starts an executable Y via Process.Start()
  3. Executable Y kills the msiexec process and run .NET Framework setup package

Here appear some problems: .NET Framework setup says that Windows Installer Service is not accessible and asks to terminate all another installations!

I think, the cause of it is that Process.Kill() method terminate the process incorrect. When I kill the msiexec process via Kill() the msiserver service is NOT STOPPABLE, but if I finish setup by clicking Cancel button, msiserver service becomes STOPPABLE.

How can I solve the problem?

回答1:

Here is how to bootstrap the .NET framework.

1) Be sure you have the .NET 3.5 and Windows Installer 3.1 boostrappers on your build machine. They should be installed with VS. They can likely be found here: C:\Program Files (x86)\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\DotNetFX35.

2) Edit the wix project file. - Right click on the project, select unload - Right click again, and edit the wixproj

3) Add the following item group:

<ItemGroup>
  <BootstrapperFile Include="Microsoft.Windows.Installer.3.1">
    <ProductName>Windows Installer 3.1</ProductName>
  </BootstrapperFile>
  <BootstrapperFile Include="Microsoft.Net.Framework.3.5.SP1">
    <ProductName>.NET Framework 3.5</ProductName>
  </BootstrapperFile>

4) Add the following at the end of the project file

    <Target Name="AfterBuild">
  <GenerateBootstrapper ApplicationFile="$(TargetFileName)" ApplicationName="My Application Name" BootstrapperItems="@(BootstrapperFile)" ComponentsLocation="Relative" CopyComponents="True" OutputPath="$(OutputPath)" Path="C:\Program Files (x86)\Microsoft SDKs\Windows\v6.0A\Bootstrapper\" /></Target>

5) Now build. The resulting setup.exe & msi should install the framework.

Scott