.net-corewix4

How do I install .net core 6 with a WIX 4 installer?


I am new to WIX and created a first installer which installs the application and other files, etc.

Now I want to add that .net Core 6 is installed as a prerequisite.

Is is correct that I need a Bundle for that and add my existing MSI into the Chain?

I looked at the WIX 3 examples but am not sure if they are still valid for WIX 4. The WIX 4 examples and tutorials I found are only based on the Product element and Bundle is not mentioned.

I found this: Installing .NET Runtime via WIX 4 Installer But it does not explain how to use it. I guess is need a Bundle to trigger the PackageGroup or can i add it to a Package?

Thanks, I really appreciate any help. I could not find much documentation on WIX 4. Especially which is helpful to a beginner...


Solution

  • The solution is indeed a Bundle installer.

    Based on Installing .NET Runtime via WIX 4 Installer I created a Fragment for the installers:

    <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"
     xmlns:netfx="http://wixtoolset.org/schemas/v4/wxs/netfx">
    
    <Fragment>
        <netfx:DotNetCoreSearch RuntimeType="desktop" MajorVersion="6" Platform="x64" Variable="DOTNETDESKTOPVERSION" />
        <PackageGroup Id="DotNetDesktopRedist">
            <ExePackage Id="DotNetDesktop"
                        DetectCondition="DOTNETDESKTOPVERSION &gt;= &quot;6.0.27&quot;"
                        Permanent="yes"
                        Vital="no"
                        InstallArguments="windowsdesktop-runtime-6.0.27-win-x64.exe /install /quiet /norestart"
                        RepairArguments="windowsdesktop-runtime-6.0.27-win-x64.exe /repair /quiet /norestart"
                        UninstallArguments="windowsdesktop-runtime-6.0.27-win-x64.exe /uninstall /quiet /norestart">
                <ExePackagePayload
                    Name="windowsdesktop-runtime-6.0.27-win-x64.exe"
                    SourceFile="..\..\..\Packages\dotnet-runtime-win-x64\6.0.27\content\windowsdesktop-runtime-6.0.27-win-x64.exe" />
            </ExePackage>
        </PackageGroup>
    
    
        <netfx:DotNetCoreSearch RuntimeType="aspnet" MajorVersion="6" Platform="x64" Variable="ASPDOTNETCOREVERSION" />
        <PackageGroup Id="AspNetCoreRedist">
            <ExePackage Id="AspNetCore"
                        DetectCondition="ASPDOTNETCOREVERSION &gt;= &quot;6.0.27&quot;"
                        Permanent="yes"
                        Vital="no"
                        InstallArguments="aspnetcore-runtime-6.0.27-win-x64.exe /install /quiet /norestart"
                        RepairArguments="aspnetcore-runtime-6.0.27-win-x64.exe /repair /quiet /norestart"
                        UninstallArguments="aspnetcore-runtime-6.0.27-win-x64.exe /uninstall /quiet /norestart">
                <ExePackagePayload
                    Name="aspnetcore-runtime-6.0.27-win-x64.exe"
                    SourceFile="..\..\..\Packages\aspnetcore-runtime-win-x64\6.0.27\content\aspnetcore-runtime-6.0.27-win-x64.exe" />
            </ExePackage>
        </PackageGroup>
    </Fragment>
    

    These PackageGroups as well as the original installer msi are then used in the Chain element of the Bundle:

    <Wix
    xmlns="http://wixtoolset.org/schemas/v4/wxs"
    xmlns:bal="http://wixtoolset.org/schemas/v4/wxs/bal">
    
    <?include Defines.wxi?>
    
    <Bundle
        Name="$(var.ApplicationName)"
        Manufacturer="$(var.ManufacturerName)"
        Version="$(var.Version)"
        UpgradeCode="YourGUID">
    
        <BootstrapperApplication>
            <bal:WixStandardBootstrapperApplication LicenseFile="My Licensing Terms.rtf"
                                                    Theme="rtfLicense" />
        </BootstrapperApplication>
    
        <Chain>
            <PackageGroupRef Id="DotNetDesktopRedist" />
            <PackageGroupRef Id="AspNetCoreRedist" />
            <MsiPackage SourceFile="..\..\Build\Installer\en-US\Installer.msi" />
        </Chain>
    
    </Bundle>
    

    The elements of the Chain are executed in the given order.