Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mac installers are not arch-aware #11164

Closed
agocke opened this issue Jul 19, 2021 · 10 comments
Closed

Mac installers are not arch-aware #11164

agocke opened this issue Jul 19, 2021 · 10 comments

Comments

@agocke
Copy link
Member

agocke commented Jul 19, 2021

Right now the installers for x64 and ARM64 will install to the same location and overwrite the other one. This results in an unusable product for both architectures.

The correct behavior is to install x64 to an x64 subdirectory when on an Apple Si machine. The apphost should decide which arch to load.

@Drenalol
Copy link

@agocke Hello.

What is the full path of x64 subdirectory should be?

@agocke
Copy link
Member Author

agocke commented Aug 11, 2021

If you're interested in performing a manual installation of the ARM64 and x64 versions of .NET on Apple Silicon, here are the steps you need to take:

  1. Download the tar.gz SDKs for both ARM64 and x64 from https://dotnet.microsoft.com/download/dotnet/6.0
  2. Unzip the ARM64 one to /usr/local/share/dotnet
  3. Unzip the x64 one to /usr/local/share/dotnet/x64
  4. Create a file at /etc/dotnet/install_location and put the following text in exactly:
/usr/local/share/dotnet/x64
arm64=/usr/local/share/dotnet

There must be no empty lines before the beginning of the text.

If you run apps by saying dotnet app.dll you'll need to pick the "right" dotnet -- /usr/local/share/dotnet/dotnet for ARM64 (which should be on your path), or /usr/local/share/dotnet/x64/dotnet for x64. If you use x64 a lot you may consider making an alias and adding it to your bashrc, like

alias dnx64="/usr/local/share/dotnet/x64/dotnet"

@Drenalol
Copy link

Yea, thank you for reply.

But i'm not understand advantage in this file /etc/dotnet/install_location.
2 and 3 step i'm already did earlier and in IDE just switched MSBuild selector for separate projects, but i'm wanna automate this routine and i’m was think this file is solution.

@agocke
Copy link
Member Author

agocke commented Aug 11, 2021

In .NET 6 we've enabled the "apphost" on Mac which is a small native exe that lives next to the app and has the same name and lets you run it, just like a native app. The apphost will try to find the correct runtime -- when /etc/dotnet/install_location is present, it will automatically find the correct runtime for the app, so you no longer need to worry about selecting the right dotnet executable.

@agocke
Copy link
Member Author

agocke commented Aug 11, 2021

In theory your IDE may also use the install_location file, but that would be specific to each IDE and whether they support that.

@Drenalol
Copy link

Drenalol commented Aug 11, 2021

In .NET 6 we've enabled the "apphost" on Mac which is a small native exe that lives next to the app and has the same name and lets you run it, just like a native app. The apphost will try to find the correct runtime -- when /etc/dotnet/install_location is present, it will automatically find the correct runtime for the app, so you no longer need to worry about selecting the right dotnet executable.

This works only in .net6.0 projects?

For example my setup:
/usr/local/share/dotnet/x64 with two SDK's .net5.0 and .net6.0 (x64)
/usr/local/share/dotnet with one SDK .net6.0 (ARM)

In the my IDE (JetBrains Rider) MSBuild set to the ARM folder, and when i build the project, it's fine, but when run it's crashes.

Failed to load /usr/local/share/dotnet/host/fxr/6.0.0-rc.1.21406.5/libhostfxr.dylib, error: dlopen(/usr/local/share/dotnet/host/fxr/6.0.0-rc.1.21406.5/libhostfxr.dylib, 1): no suitable image found. Did find: /usr/local/share/dotnet/host/fxr/6.0.0-rc.1.21406.5/libhostfxr.dylib: mach-o, but wrong architecture /usr/local/share/dotnet/host/fxr/6.0.0-rc.1.21406.5/libhostfxr.dylib: mach-o, but wrong architecture The library libhostfxr.dylib was found, but loading it from /usr/local/share/dotnet/host/fxr/6.0.0-rc.1.21406.5/libhostfxr.dylib failed

Dotnet Information (truncated):

/usr/local/share/dotnet --list-sdks
6.0.100-rc.1.21411.1 [/usr/local/share/dotnet/sdk]
/usr/local/share/dotnet/x64/dotnet --list-sdks
5.0.401 [/usr/local/share/dotnet/x64/sdk]
6.0.100-rc.1.21411.4 [/usr/local/share/dotnet/x64/sdk]
/usr/local/share/dotnet sdk check
.NET SDKs:
Version                   Status     
-------------------------------------
6.0.100-rc.1.21411.1      Up to date.

.NET Runtimes:
Name                          Version                  Status     
------------------------------------------------------------------
Microsoft.NETCore.App         6.0.0-rc.1.21406.5       Up to date.
Microsoft.AspNetCore.App      6.0.0-rc.1.21410.16      Up to date.
/usr/local/share/dotnet/x64/dotnet sdk check

Welcome to .NET 6.0!
---------------------
SDK Version: 6.0.100-rc.1.21411.4

--------------------------------------------------------------------------------------
.NET SDKs:
Version                   Status     
-------------------------------------
6.0.100-rc.1.21411.1      Up to date.

.NET Runtimes:
Name                          Version                  Status     
------------------------------------------------------------------
Microsoft.NETCore.App         6.0.0-rc.1.21406.5       Up to date.
Microsoft.AspNetCore.App      6.0.0-rc.1.21410.16      Up to date.
/usr/local/share/dotnet --info                   
.NET SDK (reflecting any global.json):
 Version:   6.0.100-rc.1.21411.1
 Commit:    172bf5a689

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  11.4
 OS Platform: Darwin
 RID:         osx.11.0-arm64
 Base Path:   /usr/local/share/dotnet/sdk/6.0.100-rc.1.21411.1/

Host (useful for support):
  Version: 6.0.0-rc.1.21406.5
  Commit:  58efa4b797

.NET SDKs installed:
  6.0.100-rc.1.21411.1 [/usr/local/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.0-rc.1.21410.16 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.0-rc.1.21406.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
/usr/local/share/dotnet/x64/dotnet --info
.NET SDK (reflecting any global.json):
 Version:   6.0.100-rc.1.21411.4
 Commit:    04bebb4dc7

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  11.4
 OS Platform: Darwin
 RID:         osx.11.0-x64
 Base Path:   /usr/local/share/dotnet/x64/sdk/6.0.100-rc.1.21411.4/

Host (useful for support):
  Version: 6.0.0-rc.1.21411.2
  Commit:  c0662e8129

.NET SDKs installed:
  5.0.401 [/usr/local/share/dotnet/x64/sdk]
  6.0.100-rc.1.21411.4 [/usr/local/share/dotnet/x64/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 5.0.9 [/usr/local/share/dotnet/x64/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.0-rc.1.21410.16 [/usr/local/share/dotnet/x64/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 5.0.9 [/usr/local/share/dotnet/x64/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.0-rc.1.21411.2 [/usr/local/share/dotnet/x64/shared/Microsoft.NETCore.App]
cat /etc/dotnet/install_location 
/usr/local/share/dotnet/x64
arm64=/usr/local/share/dotnet

@agocke
Copy link
Member Author

agocke commented Aug 11, 2021

In the my IDE (JetBrains Rider) MSBuild set to the ARM folder, and when i build the project, it's fine, but when run it's crashes.

How are you running the application? Through Rider? That's a simple arch-mismatch error from MacOS itself, so it may be that Rider is trying to launch the application improperly. If Rider itself is running as an emulated x64 app, that might explain it.

@Drenalol
Copy link

Yes, through Rider (M1 version)

JetBrains Rider 2021.2
Build #RD-212.4746.113, built on July 30, 2021
Licensed to 
Subscription is active until May 13, 2022.
Runtime version: 11.0.11+9-b1504.13 aarch64
VM: Dynamic Code Evolution 64-Bit Server VM by JetBrains s.r.o.
macOS 11.4
.NET 6.0.0
GC: G1 Young Generation, G1 Old Generation
Memory: 1504M
Cores: 8

image

@Drenalol
Copy link

Found a way to use .net6.0 and .net5.0 together with setup below.

In Rider in Launch Profile add this override env before each start\debug project.

DOTNET_ROOT=/usr/local/share/dotnet/x64

As far as I know, dotnet run should change this env itself, depending on the version of the dotnet in project, and the RID. But in version 6.0.0-rc.2.21428.1 this doesn't work yet.

@sfoslund
Copy link
Member

This was fixed by #11813 (among other runtime/arcade PRs)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants