Jeffrey Jacobs
Jeffrey Jacobs

Reputation: 1

Wix Installer bundling Dotnet Framework 4.81 with previously built msi

I have attempted to build an installer which just bundles Dotnet Framework 4.81, and a simple test application.

I keep getting an error which says "wix.exe : error WIX0001: System.ArgumentNullException: Value cannot be null.'

I created a Bundle (Wix v4) project below is the Bundle.wxs file.

<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:bal="http://wixtoolset.org/schemas/v4/wxs/bal">
  <Bundle Name="TestBundleInstaller" Manufacturer="TODO Manufacturer" Version="1.0.0.0" UpgradeCode="d090a306-15fc-4e04-985e-83cbb3a2cf5f">
    <BootstrapperApplication>
      <bal:WixStandardBootstrapperApplication LicenseUrl="https://www.example.com/license" Theme="hyperlinkLicense" />
    </BootstrapperApplication>

    <Chain>
        <!-- TODO: Define the list of chained packages. -->
        <ExePackage DetectCondition="WIX_IS_NETFRAMEWORK_48_OR_LATER_INSTALLED" InstallArguments="/q" UninstallArguments="/q">
            <Payload SourceFile="DirectoryTo\NDP481-x86-x64-AllOS-ENU.exe"/>
        </ExePackage>
        <!-- <MsiPackage SourceFile="path\to\your.msi" /> -->
        <MsiPackage SourceFile="DirectoryTo\TestSetup.msi" />
    </Chain>

  </Bundle>
</Wix>

Below is the TestBundleInstaller.wixproj file.

<Project Sdk="WixToolset.Sdk/4.0.0">
  <PropertyGroup>
    <OutputType>Bundle</OutputType>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
    <OutputPath>bin\x64\Debug</OutputPath>
    <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
  </PropertyGroup>
  <ItemGroup>
    <None Include="NDP481-x86-x64-AllOS-ENU.exe" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="WixToolset.Bal.wixext" Version="4.0.0" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\TestSetup\TestSetup.wixproj" />
  </ItemGroup>
</Project>

Read many Wix tutorials and documentation, and I still don't understand the error I experience. Any help greatly appreciated.

Build output:

Build started...

1>------ Skipped Build: Project: Test, Configuration: Debug x64 ------

1>Project not selected to build for this solution configuration

2>------ Skipped Build: Project: TestSetup, Configuration: Debug x64 ------

2>Project not selected to build for this solution configuration

3>------ Build started: Project: TestBundleInstaller, Configuration: Debug x64 ------

Restored C:\Users\JJacobs\source\repos\TestBundleInstaller\TestBundleInstaller.wixproj (in 2 ms).

3>wix.exe : error WIX0001: System.ArgumentNullException: Value cannot be null.

3>Done building project "TestBundleInstaller.wixproj" -- FAILED.

========== Build: 0 succeeded, 1 failed, 0 up-to-date, 2 skipped ==========

Upvotes: 0

Views: 583

Answers (5)

Jeffrey Jacobs
Jeffrey Jacobs

Reputation: 1

Here's how to use a registry search in a v4 bundle project.

<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:bal="http://wixtoolset.org/schemas/v4/wxs/bal" xmlns:bal.util="http://wixtoolset.org/schemas/v4/wxs/util">

    <Bundle Name="TestBundleInstaller" Manufacturer="TODO Manufacturer" Version="1.0.0.0" UpgradeCode="d090a306-15fc-4e04-985e-83cbb3a2cf5f">
        <BootstrapperApplication>
            <bal:WixStandardBootstrapperApplication LicenseUrl="https://www.example.com/license" Theme="hyperlinkLicense" />
        </BootstrapperApplication>
        <bal.util:RegistrySearch
            Id="SEARCH_DOTNET_RELEASE64"
            Variable="DotNetRelaseVariable64"
            Root="HKLM"
            Key="SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full"
            Value="Release"
            Result="value"
            Bitness="always64" />
        <Chain>
            <ExePackage DetectCondition="DotNetRelaseVariable64 &gt;= 533320"
                SourceFile="DirectoryTo\NDP481-x86-x64-AllOS-ENU.exe"
                InstallArguments="/norestart /q" UninstallArguments="/q">
            </ExePackage>
            <!-- TODO: Define the list of chained packages. -->
            <!-- ExePackage DetectCondition="WIX_IS_NETFRAMEWORK_481_OR_LATER_INSTALLED" InstallArguments="/norestart /q" UninstallArguments="/q"
                SourceFile="DirectoryTo\NDP481-x86-x64-AllOS-ENU.exe" -->
                <!-- Payload SourceFile="DirecotryTo\NDP481-x86-x64-AllOS-ENU.exe"/ -->
            <!-- /ExePackage -->
            <!-- <MsiPackage SourceFile="path\to\your.msi" /> -->
            <MsiPackage SourceFile="DirectoryTo\TestSetup.msi"/>
        </Chain>
    </Bundle>

</Wix>

Upvotes: 0

Jeffrey Jacobs
Jeffrey Jacobs

Reputation: 1

For completeness here is the new Bundle.wxs file.

<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs" xmlns:bal="http://wixtoolset.org/schemas/v4/wxs/bal">

    <Bundle Name="TestBundleInstaller" Manufacturer="TODO Manufacturer" Version="1.0.0.0" UpgradeCode="d090a306-15fc-4e04-985e-83cbb3a2cf5f">
        <BootstrapperApplication>
            <bal:WixStandardBootstrapperApplication LicenseUrl="https://www.example.com/license" Theme="hyperlinkLicense" />
        </BootstrapperApplication>
        
        <Chain>
            <!-- TODO: Define the list of chained packages. -->
            <ExePackage DetectCondition="WIX_IS_NETFRAMEWORK_481_OR_LATER_INSTALLED" InstallArguments="/norestart /q" UninstallArguments="/q"
                SourceFile="DirectoryTo\NDP481-x86-x64-AllOS-ENU.exe">
                <!-- Payload SourceFile="DirectoryTo\NDP481-x86-x64-AllOS-ENU.exe"/ -->
            </ExePackage>
            <!-- <MsiPackage SourceFile="path\to\your.msi" /> -->
            <MsiPackage SourceFile="DirectoryTo\TestSetup.msi"/>
        </Chain>

    </Bundle>
</Wix>

Upvotes: 0

Jeffrey Jacobs
Jeffrey Jacobs

Reputation: 1

using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;

namespace TestCShorpInstaller
{
    class Program
    {
        static void Main(string[] args)
        {
            System.Diagnostics.Process installerProcess = new Process();
            System.Diagnostics.ProcessStartInfo processInfo = new ProcessStartInfo();

            RegistryKey key = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v4\\Full");
            if (key != null)
            {
                Object o = key.GetValue("Release");
                Int32 releaseVal = (Int32)o;
                if( releaseVal < 533320) {
                    processInfo.FileName = ".\\NDP481-x86-x64-AllOS-ENU.exe";
                    installerProcess.StartInfo = processInfo;   
                    installerProcess.Start();
                    installerProcess.WaitForExit();
                }

            }

            installerProcess = new Process();
            processInfo = new ProcessStartInfo();
            processInfo.Arguments = @"/i TestSetup.msi";
            processInfo.FileName = "msiexec";
            installerProcess.StartInfo = processInfo;
            installerProcess.Start();
            installerProcess.WaitForExit();
        }
    }
}

Upvotes: -2

Rob Mensching
Rob Mensching

Reputation: 36006

The root issue is that ExePackage needs a SourceFile attribute. In this case, move your Payload element to the ExePackage like so:

<ExePackage DetectCondition="WIX_IS_NETFRAMEWORK_48_OR_LATER_INSTALLED"
            InstallArguments="/q" UninstallArguments="/q"
            SourceFile="DirectoryTo\NDP481-x86-x64-AllOS-ENU.exe" />

WiX v4 should have caught that as an error instead of crashing. The code in WiX for this case is complicated due to remote payloads.

I see an issue is already open, so it can get fixed in WiX.

Upvotes: 0

Bob Arnson
Bob Arnson

Reputation: 21896

The ArgumentNullException is a bug in WiX. Please file an issue: https://wixtoolset.org/docs/gethelp/#bugs

Upvotes: 1

Related Questions