Merge pull request #11813 from sfoslund/MacInstallersChoice

Add x64 emulation support to pkg installers
This commit is contained in:
Sarah Oslund 2021-09-20 15:52:41 -07:00 committed by GitHub
commit a9c86cb905
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 107 additions and 1 deletions

View file

@ -14,6 +14,7 @@
<SdkProductArchiveId>com.microsoft.dotnet.dev.$(Version).osx.$(Architecture)</SdkProductArchiveId>
<PkgInstallDirectory>/usr/local/share/dotnet</PkgInstallDirectory>
<x64EmulationPkgInstallDirectory>/usr/local/share/dotnet/x64</x64EmulationPkgInstallDirectory>
<SdkPkgSourcesRootDirectory>$(MSBuildThisFileDirectory)packaging/osx/clisdk</SdkPkgSourcesRootDirectory>
<SdkPkgScriptsDirectory>$(SdkPkgSourcesRootDirectory)/scripts</SdkPkgScriptsDirectory>
@ -22,7 +23,8 @@
<SdkPkgScriptFile>$(SdkPkgDestinationScriptsDirectory)/postinstall</SdkPkgScriptFile>
<SdkProductArchiveResourcesDirectory>$(PkgIntermediateDirectory)/resources</SdkProductArchiveResourcesDirectory>
<SdkProductArchiveDistributionTemplateFile>$(SdkPkgSourcesRootDirectory)/Distribution-Template</SdkProductArchiveDistributionTemplateFile>
<SdkProductArchiveDistributionTemplateFile Condition="'$(Architecture)' != 'x64'">$(SdkPkgSourcesRootDirectory)/Distribution-Template</SdkProductArchiveDistributionTemplateFile>
<SdkProductArchiveDistributionTemplateFile Condition="'$(Architecture)' == 'x64'">$(SdkPkgSourcesRootDirectory)/Distribution-Template-x64</SdkProductArchiveDistributionTemplateFile>
<SdkProductArchiveDistributionFile>$(PkgIntermediateDirectory)/CLI-SDK-Formatted-Distribution-Template.xml</SdkProductArchiveDistributionFile>
<SdkPkgIntermediatePath>$(PkgIntermediateDirectory)/$(SdkComponentId).pkg</SdkPkgIntermediatePath>
@ -96,6 +98,9 @@
<ReplacementString>10.13</ReplacementString>
<ReplacementString Condition="'$(Architecture)' == 'arm64'" >11.0</ReplacementString>
</DistributionTemplateReplacement>
<DistributionTemplateReplacement Include="{x64EmulationPkgInstallDirectory}">
<ReplacementString>$(x64EmulationPkgInstallDirectory)</ReplacementString>
</DistributionTemplateReplacement>
<PostInstallScriptReplacement Include="%SDK_VERSION%">
<ReplacementString>$(Version)</ReplacementString>

View file

@ -0,0 +1,101 @@
<?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>