I have read many, many, many StackOverflow posts on this subject and many Internet articles but none answer this simple question:
Is it possible to build a single file macOS console application written in C# that depends upon .NET Core 3.1?
I am coding using Visual Studio (Community Edition) on macOS Catalina. I have the simplest test console app project created (in VS) using the Console Application template:
Here is the code for the app:
using System;
namespace TestApp
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
If I run this in Visual Studio it works.
If I build the app, set to Release:
Then I get this in the output folder:
I can run TestApp.dll from the Terminal using dotnet TestApp.dll. This obviously requires the end user to have the .NET framework installed on their computer (otherwise they can't call the dotnet tool).
I have tried publishing the project using the dotnet CLI to build a standalone app. I used this command:
dotnet publish -c Release --self-contained -r osx-x64
taken from this post.
Whilst this generates a TestApp binary, it also generates 192 other files like so:
Is there any way that these DLLs can be bundled into the TestApp binary? Any solutions I have come across are either Windows only or are 5 years out of date (and no longer work).
I feel sure this must be a solved problem. I don't care if I have to build the app via the command line (if the Mac VS doesn't support it).



