R – WiX changes required to streamline .NET 3.5 installation for Vista (and above) machines

.net-3.5upgradewindows-installerwix

We have decided to take the plunge and require that our users have .NET 3.5 installed before they can use our media center plug-in.

I want to make sure the install experience is as smooth as possible and that our installer stays small.

What changes do I need to make to my WiX file to support the following scenarios? Code examples would be much appreciated.

  • User has .Net framework 3.0 installed, interactive install.

Desired Behavior: User is prompted with a window that tells her she needs a new version of the framework, if she accepts, dotNetFx35setup.exe (2.7 MB) is downloaded, and then executed. Finally, the installation proceeds.

  • User has .Net framework 3.0 installed, non-interactive install.

Background: To facilitate auto-updates from within media center, we may execute "msiexec.exe /qb /i mediabrowser.msi" if a user elect to upgrade an existing version.

Desired behavior: User is prompted with a window that tells her she needs a new version of the framework, if she accepts, dotNetFx35setup.exe (2.7 MB) is downloaded, and then executed. Finally, the installation proceeds silently.

Are there any other open source projects that implement something along these lines?

Related question: Is .NET 3.5 a reasonable pre-requisite for a media center plugin?

Best Answer

I believe installing .NET falls under the responsibilities of a setup.exe bootstrapper, before your msi is launched. WIX does not (yet) have its own way to generate a bootstrapper (or if it does, it is not documented in wix.chm). Instead, you can make use of the GenerateBootStrapper msbuild task to generate a setup.exe. Take a look at the topic "How To: Install the .NET Framework Using a Bootstrapper" in the wix documentation. To install .NET 3.5 SP1 by download, your msbuild file would like this:

<Project ToolsVersion="3.5"
   xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

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

    <Target Name="SetupExe">
        <GenerateBootstrapper
            ApplicationFile="myproduct.msi"
            ApplicationName="myproduct"
            BootstrapperItems="@(BootstrapperFile)"
            Path="C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bootstrapper\"
            OutputPath="path/to/put/setup/"
            Culture="en"/>
    </Target>

</Project>

If you save the above in a setup.msbuild file, you can build your setup by invoking

C:\WINDOWS\Microsoft.NET\Framework\v3.5\msbuild.exe setup.msbuild

You can also install .NET from your install CD rather than downloading it. Just add ComponentsLocation="Relative" to the attributes of GenerateBootstrapper.