Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions src/Common/wix/dotnethome_x64.wxs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. -->
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<?ifndef Platform?>
<?define Platform = "$(sys.BUILDARCH)"?>
<?endif?>

<!-- InstallerArchitecture matches the expected values for PROCESSOR_ARCHITECTURE
https://docs.microsoft.com/en-us/windows/win32/winprog64/wow64-implementation-details -->
<?if $(var.Platform)~=x86?>
<?define InstallerArchitecture="X86"?>
<?elseif $(var.Platform)~=x64?>
<?define InstallerArchitecture="AMD64"?>
<?elseif $(var.Platform)~=arm64?>
<?define InstallerArchitecture="ARM64"?>
<?else?>
<?error Unknown platform, $(var.Platform) ?>?
<?endif?>

<Fragment>
<!-- Identify when installing in emulation as when PROCESSOR_ARCHITECTURE does not match the installer architecture
https://docs.microsoft.com/en-us/windows/win32/winprog64/wow64-implementation-details -->
<SetProperty Action="Set_NON_NATIVE_ARCHITECTURE" Id="NON_NATIVE_ARCHITECTURE" Value="true" Before="CostFinalize">
NOT %PROCESSOR_ARCHITECTURE="$(var.InstallerArchitecture)"
</SetProperty>
</Fragment>

<?if $(var.Platform)~=x64?>
<Fragment>
<!-- When running in a non-native architecture and user hasn't specified install directory,
install to an x64 subdirectory.
This is only define for x64, since x86 has redirection and no other native architecture can install ARM64 today -->
<SetProperty Action="Set_DOTNETHOME_NON_NATIVE_ARCHITECTURE" Id="DOTNETHOME" Value="[ProgramFiles64Folder]dotnet\x64\" After="Set_NON_NATIVE_ARCHITECTURE">
NON_NATIVE_ARCHITECTURE AND NOT DOTNETHOME
</SetProperty>
</Fragment>
<?endif?>
</Wix>
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<None Include="build/**/*.*" Pack="true">
<PackagePath>build</PackagePath>
</None>
<None Include="..\Common\wix\dotnethome_x64.wxs" Link="build\wix\product\dotnethome_x64.wxs" PackagePath="%(Link)" Pack="true" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net472'">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@
RemoveProperties="@(_GlobalPropertiesToRemoveForPublish)" />
<PropertyGroup>
<_MacOSVersionComponent Condition="'$(IncludeVersionInMacOSComponentName)' == 'true'">.$(InstallerPackageVersion)</_MacOSVersionComponent>
<_MacOSComponentName Condition="'$(_MacOSComponentName)' == ''">com.microsoft.dotnet.$(MacOSComponentNamePackType)$(_MacOSVersionComponent).component.osx.x64</_MacOSComponentName>
<_MacOSComponentName Condition="'$(_MacOSComponentName)' == ''">com.microsoft.dotnet.$(MacOSComponentNamePackType)$(_MacOSVersionComponent).component.osx.$(InstallerTargetArchitecture)</_MacOSComponentName>
<_MacOSSharedInstallDir>/usr/local/share/dotnet</_MacOSSharedInstallDir>

<_pkgArgs></_pkgArgs>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@
<PayloadGroupRef Id="DotnetCoreBAPayloads" />
</BootstrapperApplicationRef>

<swid:Tag Regid="microsoft.com" InstallPath="[DOTNETHOME]" />

<Variable Name="DOTNETHOME" Type="string" Value="[$(var.Program_Files)]dotnet" bal:Overridable="no" />
<swid:Tag Regid="microsoft.com" InstallPath="[$(var.Program_Files)]dotnet" />

<!-- Variables used solely for localization. -->
<Variable Name="BUNDLEMONIKER" Type="string" Value="$(var.ProductMoniker) ($(var.TargetArchitectureDescription))" bal:Overridable="no" />
Expand All @@ -54,9 +52,7 @@

<Chain DisableSystemRestore="yes" ParallelCache="yes">
<?foreach chainedFile in $(var.ChainedDotNetPackageFiles)?>
<MsiPackage SourceFile="$(var.chainedFile)">
<MsiProperty Name="DOTNETHOME" Value="[DOTNETHOME]" />
</MsiPackage>
<MsiPackage SourceFile="$(var.chainedFile)" />
<?endforeach?>
</Chain>
</Bundle>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. -->
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">

<?include "..\variables.wxi" ?>
Expand Down Expand Up @@ -51,6 +52,9 @@
<Directory Id="DOTNETHOME" Name="dotnet" />
</Directory>
</Directory>
</Fragment>

<?if $(var.Platform)~=x64?>
<CustomActionRef Id="Set_DOTNETHOME_NON_NATIVE_ARCHITECTURE" />
<?endif?>
</Fragment>
</Wix>
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
<WixExtensions Include="WixUtilExtension.dll" />

<WixSrcFile Include="$(MSBuildThisFileDirectory)product/product.wxs" />
<WixSrcFile Include="$(MSBuildThisFileDirectory)product/dotnethome_x64.wxs" />
<WixSrcFile Include="$(MSBuildThisFileDirectory)product/provider.wxs" />
</ItemGroup>
</Target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public class GenerateMacOSDistributionFile : BuildTask
[Required]
public string DestinationFile { get; set; }

public string Alternativex64InstallPath { get; set; }

public override bool Execute()
{
try
Expand All @@ -38,7 +40,24 @@ public override bool Execute()

var titleElement = new XElement("title", $"{ProductBrandName} ({TargetArchitecture})");

var choiceLineElements = BundledPackages.Select(component => new XElement("line", new XAttribute("choice", component.GetMetadata("FileNameWithExtension"))));
var archScriptContent = @"<![CDATA[
function IsX64Machine() {
var machine = system.sysctl(""hw.foo"");
var cputype = system.sysctl(""hw.cputype"");
var cpu64 = system.sysctl(""hw.cpu64bit_capable"");
system.log(""Machine type: "" + machine);
system.log(""Cpu type: "" + cputype);
system.log(""64-bit: "" + cpu64);

// 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"");
system.log(""IsX64Machine: "" + result);
return result;
}
]]>";
var scriptElement = new XElement("script", new XText(archScriptContent));

var choiceElements = BundledPackages
.Select(component => new XElement("choice",
Expand All @@ -48,6 +67,23 @@ public override bool Execute()
new XAttribute("description", component.GetMetadata("Description")),
new XElement("pkg-ref", new XAttribute("id", component.GetMetadata("FileNameWithExtension")))));

if (TargetArchitecture == "x64")
{
Alternativex64InstallPath ??= "/usr/local/share/dotnet/x64";

choiceElements =
choiceElements.Select(c => new XElement(c)
.WithAttribute("selected", "IsX64Machine()"))
.Concat(
choiceElements.Select(c => new XElement(c)
.WithAttribute("id", c.Attribute("id").Value + ".alternate")
.WithAttribute("selected", "!IsX64Machine()")
.WithAttribute("customLocation", Alternativex64InstallPath)));
}

var choiceLineElements = choiceElements
.Select(c => new XElement("line", new XAttribute("choice", c.Attribute("id").Value)));

var pkgRefElements = BundledPackages
.Select(component => new XElement("pkg-ref",
new XAttribute("id", component.GetMetadata("FileNameWithExtension")),
Expand Down Expand Up @@ -78,6 +114,7 @@ public override bool Execute()
document.Root.Add(new XElement("choices-outline", choiceLineElements));
document.Root.Add(choiceElements);
document.Root.Add(pkgRefElements);
document.Root.Add(scriptElement);
using XmlWriter writer = XmlWriter.Create(File.OpenWrite(DestinationFile));
document.WriteTo(writer);
}
Expand All @@ -89,4 +126,13 @@ public override bool Execute()
return true;
}
}

static class XElementExtensions
{
public static XElement WithAttribute(this XElement element, XName attribute, object value)
{
element.SetAttributeValue(attribute, value);
return element;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ static EmbeddedTemplates()
{
{ "DependencyProvider.wxs", $"{s_namespace}.MsiTemplate.DependencyProvider.wxs" },
{ "Directories.wxs", $"{s_namespace}.MsiTemplate.Directories.wxs" },
{ "dotnethome_x64.wxs", $"{s_namespace}.MsiTemplate.dotnethome_x64.wxs" },
{ "ManifestProduct.wxs", $"{s_namespace}.MsiTemplate.ManifestProduct.wxs" },
{ "Product.wxs", $"{s_namespace}.MsiTemplate.Product.wxs" },
{ "Registry.wxs", $"{s_namespace}.MsiTemplate.Registry.wxs" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ public override bool Execute()
List<string> sourceFiles = new();
string msiSourcePath = Path.Combine(MsiDirectory, $"{nupkg.Id}", $"{nupkg.Version}", platform);
sourceFiles.Add(EmbeddedTemplates.Extract("DependencyProvider.wxs", msiSourcePath));
sourceFiles.Add(EmbeddedTemplates.Extract("dotnethome_x64.wxs", msiSourcePath));
sourceFiles.Add(EmbeddedTemplates.Extract("ManifestProduct.wxs", msiSourcePath));

string EulaRtfPath = Path.Combine(msiSourcePath, "eula.rtf");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ protected IEnumerable<ITaskItem> Generate(string sourcePackage, string swixPacka
string msiSourcePath = Path.Combine(MsiDirectory, $"{nupkg.Id}", $"{nupkg.Version}", platform);
sourceFiles.Add(EmbeddedTemplates.Extract("DependencyProvider.wxs", msiSourcePath));
sourceFiles.Add(EmbeddedTemplates.Extract("Directories.wxs", msiSourcePath));
sourceFiles.Add(EmbeddedTemplates.Extract("dotnethome_x64.wxs", msiSourcePath));
sourceFiles.Add(EmbeddedTemplates.Extract("Product.wxs", msiSourcePath));
sourceFiles.Add(EmbeddedTemplates.Extract("Registry.wxs", msiSourcePath));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
<EmbeddedResource Include="Misc\*.*" />
<EmbeddedResource Include="MsiTemplate\*.wxs" />
<EmbeddedResource Include="MsiTemplate\*.wxi" />
<EmbeddedResource Include="..\..\Common\wix\dotnethome_x64.wxs" Link="MsiTemplate\dotnethome_x64.wxs" />
<EmbeddedResource Include="SwixTemplate\*.swr" />
<EmbeddedResource Include="SwixTemplate\*.swixproj" />
<EmbeddedResource Include="SwixTemplate\*.vsmanproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,9 @@
</Directory>
</Directory>
</Directory>

<?if $(var.Platform)~=x64?>
<CustomActionRef Id="Set_DOTNETHOME_NON_NATIVE_ARCHITECTURE" />
<?endif?>
</Fragment>
</Wix>
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
</Directory>
</Directory>

<?if $(var.Platform)~=x64?>
<CustomActionRef Id="Set_DOTNETHOME_NON_NATIVE_ARCHITECTURE" />
<?endif?>

<MediaTemplate CompressionLevel="high" EmbedCab="yes" />

<!-- Record the original package used to generate the MSI -->
Expand Down