Apologies if the question seems basic, but I did some Googling and couldn't find a clear answer (Perhaps I don't know the right keywords).
Can .NET Core be used to build native command-line Linux binaries from C# / F# sources? (I'm aware of Mono)
Apologies if the question seems basic, but I did some Googling and couldn't find a clear answer (Perhaps I don't know the right keywords).
Can .NET Core be used to build native command-line Linux binaries from C# / F# sources? (I'm aware of Mono)
Yeah, it can. I've messed with it a bit.
dotnet new console
...
dotnet publish -c release -r linux-x64
Or something along those lines... It's been a while since I messed with it, but there is help and tutorials out there for doing dotnet on Linux and I've gotten it to work just fine on CentOS 7. Of course, I did this on a Linux machine and not from a Windows machine. If your asking if you can create a console (command-line) app on Windows for Linux with .NET Core, I don't know.
AOT is a feature available starting from dotnet 7.0, even though it has a few limitations such as currently being available only for console applications, requiring trimming which also has some limitations and not all dotnet libraries being compatible with it (see more information at the provided links).
In order to enable AOT, in your .csproj
:
<PropertyGroup>
<!-- enabled aot publishing -->
<PublishAot>true</PublishAot>
<!-- reduces binary size, no debug symbols -->
<StripSymbols>true</StripSymbols>
</PropertyGroup>
$ dotnet publish --runtime <RID> --configuration <Debug | Release>
Hello world application, native binary size and memory consumption.
© 2022 - 2024 — McMap. All rights reserved.