Michal
Michal
CC#
Created by Jelle on 10/26/2023 in #help
❔ Distributing a CLI app (with .NET 8 Native AOT)
Putting <PropertyGroup><TrimMode>partial</TrimMode></PropertyGroup> in the csproj will likely clear the problem up, but you'll be left with a bigger app that you can't be sure really works (you need to retest all codepaths after publishing and keep doing that every time you make a change). as the warnings say, you chose nuget packages that are not compatible with trimming. there are other command line parsers that work fine with trimming. System.CommandLine should. I think Mono.Options does too. I don't know about YAML parsers. But if you want AOT, you need to pay attention to the warnings and choose your dependencies so that they don't generate the warnings
4 replies
CC#
Created by ascpixi on 8/28/2023 in #help
❔ Does the import-by-ordinal functionality of DllImport work under NAOT + DirectPInvoke?
The way ordinal imports work is through linker magic. If you make a simple C file (e.g. void hello(void) { printf("Hello, world!\n"); } and a matching DEF file (e.g. LIBRARY lib\nEXPORTS\n hello @1 NONAME (replace \n with newlines) and compile as cl lib.c /LD /link /def:lib.def you'll get an import library (*.lib) that exports a symbol named hello. you just dllimport the hello from C# side and then pass the import library to linker. linker will match up hello with the ordinal and import as such (leaving no trace of the name hello in the final executable)
12 replies