Home > Software engineering >  How do I target arm64 on a net7.0-macos project?
How do I target arm64 on a net7.0-macos project?

Time:11-21

I'm building a multi targeted app with frameworks net7.0-windows;net7.0-macos.

When I build the project, it is building to bin/Debug/net7.0-macos/osx-x64.

I'd like for it to target arm64 since I'm on an M1 mac.

Is this possible?

CodePudding user response:

With .NET Core, you don't need to target a specific architecture, you just deploy for it, using e.g.

dotnet publish MyProject.csproj --runtime linux-arm64

This will create the bin/Debug/net7.0/publish folder with the project prepared for arm64.

However, that will most likely result in an error if your project targets net7.0-windows;net7.0-macos. You need to have a generic target specifier such as only net7.0. The operating-system specific targets net7.0-windows and net7.0-macos are only required if you use libraries that are only available for these frameworks, such as WPF or WinForms. Since you already target macos, I doubt you're using any of these, so why aren't you just using the generic net7.0 target?

  • Related