<?xml version="1.0" encoding="utf-8" standalone="no"?>
<installer-gui-script minSpecVersion="1">
    <title>{CLISdkBrandName} ({arch})</title>
    <background file="dotnetbackground.png" mime-type="image/png"/>
    <options customize="never" require-scripts="false" hostArchitectures="{hostArchitectures}" />
    <welcome file="welcome.html" mime-type="text/html" />
    <conclusion file="conclusion.html" mime-type="text/html" />
    <volume-check>
        <allowed-os-versions>
            <os-version min="{minOsVersion}" />
        </allowed-os-versions>
    </volume-check>
    <choices-outline>
        <line choice="{NetCoreAppTargetingPackComponentId}.pkg.x64" />
        <line choice="{NetStandardTargetingPackComponentId}.pkg.x64" />
        <line choice="{NetCoreAppHostPackComponentId}.pkg.x64" />
        <line choice="{SharedFxComponentId}.pkg.x64" />
        <line choice="{HostFxrComponentId}.pkg.x64" />
        <line choice="{SharedHostComponentId}.pkg.x64" />
        <line choice="{CLISdkComponentId}.pkg.x64"/>
        <line choice="{NetCoreAppTargetingPackComponentId}.pkg.arm64" />
        <line choice="{NetStandardTargetingPackComponentId}.pkg.arm64" />
        <line choice="{NetCoreAppHostPackComponentId}.pkg.arm64" />
        <line choice="{SharedFxComponentId}.pkg.arm64" />
        <line choice="{HostFxrComponentId}.pkg.arm64" />
        <line choice="{SharedHostComponentId}.pkg.arm64" />
        <line choice="{CLISdkComponentId}.pkg.arm64"/>
    </choices-outline>
    <choice id="{NetCoreAppTargetingPackComponentId}.pkg.x64" visible="true" selected="IsX64Machine()" title="{NetCoreAppTargetingPackBrandName} ({arch})" description="The .NET Targeting Pack">
        <pkg-ref id="{NetCoreAppTargetingPackComponentId}.pkg" />
    </choice>
    <choice id="{NetStandardTargetingPackComponentId}.pkg.x64" visible="true" selected="IsX64Machine()" title="{NetStandardTargetingPackBrandName} ({arch})" description="The .NET Standard 2.1 Targeting Pack">
        <pkg-ref id="{NetStandardTargetingPackComponentId}.pkg" />
    </choice>
    <choice id="{NetCoreAppHostPackComponentId}.pkg.x64" visible="true" selected="IsX64Machine()" title="{NetCoreAppHostPackBrandName} ({arch})" description="The .NET App Host Pack">
        <pkg-ref id="{NetCoreAppHostPackComponentId}.pkg" />
    </choice>
    <choice id="{SharedFxComponentId}.pkg.x64" visible="true" selected="IsX64Machine()" title="{SharedFxBrandName} ({arch})" description="The .NET Shared Framework">
        <pkg-ref id="{SharedFxComponentId}.pkg" />
    </choice>
    <choice id="{HostFxrComponentId}.pkg.x64" visible="true" selected="IsX64Machine()" title="{HostFxrBrandName} ({arch})" description="The .NET Host FX Resolver">
        <pkg-ref id="{HostFxrComponentId}.pkg" />
    </choice>
    <choice id="{SharedHostComponentId}.pkg.x64" visible="true" selected="IsX64Machine()" title="{SharedHostBrandName} ({arch})" description="The .NET Shared Host.">
        <pkg-ref id="{SharedHostComponentId}.pkg" />
    </choice>
    <choice id="{CLISdkComponentId}.pkg.x64" visible="true" selected="IsX64Machine()" title="{CLISdkBrandName} ({arch})" description="The .NET SDK">
        <pkg-ref id="{CLISdkComponentId}.pkg"/>
    </choice>
    <choice id="{NetCoreAppTargetingPackComponentId}.pkg.arm64" visible="true" selected="!IsX64Machine()" customLocation="{x64EmulationPkgInstallDirectory}" title="{NetCoreAppTargetingPackBrandName} ({arch})" description="The .NET Targeting Pack">
        <pkg-ref id="{NetCoreAppTargetingPackComponentId}.pkg" />
    </choice>
    <choice id="{NetStandardTargetingPackComponentId}.pkg.arm64" visible="true" selected="!IsX64Machine()" customLocation="{x64EmulationPkgInstallDirectory}" title="{NetStandardTargetingPackBrandName} ({arch})" description="The .NET Standard 2.1 Targeting Pack">
        <pkg-ref id="{NetStandardTargetingPackComponentId}.pkg" />
    </choice>
    <choice id="{NetCoreAppHostPackComponentId}.pkg.arm64" visible="true" selected="!IsX64Machine()" customLocation="{x64EmulationPkgInstallDirectory}" title="{NetCoreAppHostPackBrandName} ({arch})" description="The .NET App Host Pack">
        <pkg-ref id="{NetCoreAppHostPackComponentId}.pkg" />
    </choice>
    <choice id="{SharedFxComponentId}.pkg.arm64" visible="true" selected="!IsX64Machine()" customLocation="{x64EmulationPkgInstallDirectory}" title="{SharedFxBrandName} ({arch})" description="The .NET Shared Framework">
        <pkg-ref id="{SharedFxComponentId}.pkg" />
    </choice>
    <choice id="{HostFxrComponentId}.pkg.arm64" visible="true" selected="!IsX64Machine()" customLocation="{x64EmulationPkgInstallDirectory}" title="{HostFxrBrandName} ({arch})" description="The .NET Host FX Resolver">
        <pkg-ref id="{HostFxrComponentId}.pkg" />
    </choice>
    <choice id="{SharedHostComponentId}.pkg.arm64" visible="true" selected="!IsX64Machine()" customLocation="{x64EmulationPkgInstallDirectory}" title="{SharedHostBrandName} ({arch})" description="The .NET Shared Host.">
        <pkg-ref id="{SharedHostComponentId}.pkg" />
    </choice>
    <choice id="{CLISdkComponentId}.pkg.arm64" visible="true" selected="!IsX64Machine()" customLocation="{x64EmulationPkgInstallDirectory}" title="{CLISdkBrandName} ({arch})" description="The .NET SDK">
        <pkg-ref id="{CLISdkComponentId}.pkg"/>
    </choice>
    <pkg-ref id="{NetCoreAppTargetingPackComponentId}.pkg">{NetCoreAppTargetingPackComponentId}.pkg</pkg-ref>
    <pkg-ref id="{NetStandardTargetingPackComponentId}.pkg">{NetStandardTargetingPackComponentId}.pkg</pkg-ref>
    <pkg-ref id="{NetCoreAppHostPackComponentId}.pkg">{NetCoreAppHostPackComponentId}.pkg</pkg-ref>
    <pkg-ref id="{SharedFxComponentId}.pkg">{SharedFxComponentId}.pkg</pkg-ref>
    <pkg-ref id="{HostFxrComponentId}.pkg">{HostFxrComponentId}.pkg</pkg-ref>
    <pkg-ref id="{SharedHostComponentId}.pkg">{SharedHostComponentId}.pkg</pkg-ref>
    <pkg-ref id="{CLISdkComponentId}.pkg">{CLISdkComponentId}.pkg</pkg-ref>
    <script>
<![CDATA[
function IsX64Machine() {
    var machine = system.sysctl("hw.machine");
    var cputype = system.sysctl("hw.cputype");
    var cpu64 = system.sysctl("hw.cpu64bit_capable");
    var translated = system.sysctl("sysctl.proc_translated");
    system.log("Machine type: " + machine);
    system.log("Cpu type: " + cputype);
    system.log("64-bit: " + cpu64);
    system.log("Translated: " + translated);
    
    // From machine.h
    // CPU_TYPE_X86_64 = CPU_TYPE_X86 | CPU_ARCH_ABI64 = 0x010000007 = 16777223
    // CPU_TYPE_X86 = 7
    var result = machine == "amd64" || machine == "x86_64" || cputype == "16777223" || (cputype == "7" && cpu64 == "1");
    // We may be running under translation (Rosetta) that makes it seem like system is x64, if so assume machine is not actually x64
    result = result && (translated != "1");
    system.log("IsX64Machine: " + result);
    return result;
}
]]>
    </script>
</installer-gui-script>
