Search code examples
.netvisual-studiowixwindows-installer

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 ==========


Solution

  • 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.