Skip to content

[Feature] Yubico.NativeShims doesn't build as expected with AOT #60

@SheepReaper

Description

@SheepReaper

When building an executable the native AOT compiler, Yubico.NativeShims.dll is output next to the executable instead of being trimmed away. There are also no compiler warnings about dependencies having trimming issues, which is odd. But I suspect it has to do with native shims being pre-built/native or shared vs static, it's not IL. It probably needs to be IL or static, or maybe static with a p/invoke wrapper class, in order for trimming to work (not sure haven't done one of these myself before).

Expected output

single executable with no libraries around it

What's actually happening

Yubico.NativeShims.dll in the output dir.

Steps to reproduce

  • dotnet new console
  • dotnet add package Yubico.YubiKey
  • Add <PublishAot>true</PublishAot> to the project file
  • dotnet publish -o ./out

Sample with expected output

Instead of adding the YubiKey reference add one to Newtonsoft.Json
You should get a ton of warnings about trimming, but the output is as expected absent of any Newtonsoft libs.

Why do I want this?

if you take a peek at my latest builds: https://github.com/SheepReaper/yk-csr-generator/releases/tag/v1.0.0 I'm building 80MB assemblies because of the runtime bits included. Granted, if I didn't do single file, it would be way smaller, but then the user needs to have a runtime installed. I just want to build a single executable with no external dependencies, so I'm fine with the bloat.
However, in testing AOT builds, I was able to achieve a 1.5KB binary plus the Shim lib next to it with almost 3KB. Which is super nice, but we're back at the original problem of external dependencies.

Additional references

I don't know enough about the Shims lib to determine what about it is preventing AOT from working nicely, but worst case it's hitting one of the many limitations of AOT compatibility, which might be too much work to overcome. In which case, I'll be sticking to my thicc binaries...

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions