3

I have an Avalonia project I'm tried to build for mac. But when I use dotnet publish to generate the build for osx, there is no executable file generated. It generates a .dll file with the same name as the program (same name as the executable should be) and also a file with no extension with the same name. To do so I use

dotnet publish "VisualStudio solution path" -c Release -f netcoreapp3.1 -r osx-x64 -p:UseAppHost=True --self-contained true -o "outputPath"

As per I read here I also added UseAppHost True in my project properties. They look like this:

<PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <RuntimeIdentifiers>win7-x64;osx-x64;ubuntu.16.04-x64</RuntimeIdentifiers>
    <Nullable>enable</Nullable>
    <LangVersion>preview</LangVersion>
    <UseAppHost>True</UseAppHost>
  </PropertyGroup>

I'm at a loss as to how to get dotnet publish to generate an actual executable file for mac. Does anyone know what I'm doing wrong and what I need to do? Thanks.

Edit: I'm doing this on windows 10.

Lex Li
  • 60,503
  • 9
  • 116
  • 147
Jeremy
  • 41
  • 6
  • 1
    Spend some time learning macOS and you will see why you’d better publish on macOS or Linux, and the file without extension is the executable. – Lex Li Dec 25 '21 at 02:46
  • But how do I run it? I right clicked it and hit open and it just opened a text edtior. I tried dotnet "filename" and it told me it wasn't signed and wouldn't let me run it. The posts I read on Avalonia suggested I might have to chmod +x on it to run it, but didn't suggest it's not a runnable file type at all. – Jeremy Dec 25 '21 at 03:18
  • 1
    How to run? `./exectuable_name` at terminal is the universal way to launch such a .NET Core app. If you want the capability to open it from Finder, you should learn how to pack things up as a `.app` file (in fact a well structured folder of files). There are examples like https://github.com/icsharpcode/AvaloniaILSpy to help you get started. – Lex Li Dec 25 '21 at 17:46
  • Ok thanks. Yes building on mac was definitely the way to go. It generated an executable as expected. And yeah good advice on app bundles, that's what I wanted. – Jeremy Jan 06 '22 at 02:00

2 Answers2

0

the bundling is possible on windows, but you'll have to fix permission, sign and notarize on a Mac

Here is the full documentation about bundling in Avalonia : https://docs.avaloniaui.net/docs/distribution-publishing/macos

Whiletrue
  • 551
  • 1
  • 7
  • 18
0

use

  <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
    <OutputType>Exe</OutputType>
    <TargetFramework>net6.0</TargetFramework>
    <RuntimeIdentifiers>win7-x64;osx-x64;ubuntu.16.04-x64</RuntimeIdentifiers>
    <Nullable>enable</Nullable>
    <LangVersion>preview</LangVersion>
    <UseAppHost>True</UseAppHost>
 <GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
Beruk Berhane
  • 449
  • 4
  • 4