Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single library output ? #30

Open
maximilien-noal opened this issue Sep 14, 2020 · 21 comments
Open

Single library output ? #30

maximilien-noal opened this issue Sep 14, 2020 · 21 comments
Labels
enhancement New feature or request

Comments

@maximilien-noal
Copy link

maximilien-noal commented Sep 14, 2020

Hello,

Thank you very much for this project !

I can finally write a libretro core with .NET 5 in a manner that is fully supported.

Is it or will it be possible to build everything in a single static library ?

I want to be able to ship only a single file per platform (Windows, Linux, Mac) like libretro cores written in C do.

It does not seem to be possible in my mind (there's got to be a proxy), but it doesn't hurt to ask.

Thank you very much again !

@jcapellman
Copy link

A couple of my use cases would prefer that as well - though not having to do a COM Interface or Embedinator 4000 is worth the switch to DNNE.

@maximilien-noal maximilien-noal changed the title Single output library ? Single library output ? Sep 14, 2020
@AaronRobinsonMSFT AaronRobinsonMSFT added the enhancement New feature or request label Sep 14, 2020
@AaronRobinsonMSFT
Copy link
Owner

Is it or will it be possible to build everything in a single static library ?

@maximilien-noal Great question. That is something I am thinking about working with @vitek-karas on supporting. There are some minor issues to handle and a few major ones, if a "self-contained" library is desired, that would need to be addressed. As an FYI we are actively discussing the inclusion of this kind of tech in .NET 6.0. Nothing is certain but as we hear more from the community we take this feedback seriously during the planning phase.

@maximilien-noal and @jcapellman

Are either of you looking at self-contained deployment or would shared-framework be fine?

/cc @jkotas

@jcapellman
Copy link

Self Contained would be preferred, but shared framework would be ok as a hold out until .NET 6

@maximilien-noal
Copy link
Author

Either is very fine, even if self-contained would be interesting to ease shipping even more.

@NickAcPT
Copy link

I too would love to see this be implemented. For me, self-contained would be super amazing, but shared framework is also fine.

@AlexandreGarino
Copy link

IMHO, both of the two approaches should be available.

@LeonarddeR
Copy link

I'd also really like selfcontained export for this to be available!

@govert
Copy link

govert commented Dec 6, 2020

I would prefer a single-file library, but targeting shared-framework. This is because I am loading into a hostile native process (Excel) and need to share with other libraries, so would prefer to support the newest framework on the machine.

@esso23
Copy link

esso23 commented Apr 6, 2021

This would be great. Currently we are still forced to use net472 - we are using DllExport for unmanaged exports and Costura.Fody for single library output. This feature would finally make it possible to migrate to .NET 5.

@bitapparat
Copy link

Any news on self-contained publishing, now that .NET 6 is available? I want to provide a plugin for a native application, ideally developed in .NET 6 and self-contained.

@AaronRobinsonMSFT
Copy link
Owner

@bitapparat I am sort of reluctant to evangelize this functionality but I did add basic support in an experimental way. Getting it to work is not for the faint of heart but that is mostly an issue with collecting all the needed .NET components and putting them in the right place. The DNNE support is as good as it can get given the current library support for self-contained in .NET.

<!-- EXPERIMENTAL: The native hosting should assume it is in a self-contained scenario.
When setting this flag to true, the only change in output will be the generated hosting
layer will call an API that will permit self-contained runtime activation. In order for this
option to work as desired the user must have manually configured the assembly's runtimeconfig.json
file and deps.json file. The user must also copy the appropriate runtime binaries to create a
valid self-contained install environment. -->
<DnneSelfContained_Experimental>false</DnneSelfContained_Experimental>

@climblinne
Copy link
Contributor

Just to clarify, I looked into .net 6.0 and recognize, that the single library output will be only available for "executables". Did I miss anything, how it can be made elsewhere?

@ThaDaVos
Copy link

Any updates on the above?

@vitek-karas
Copy link
Collaborator

NativeAOT can produce self-contained native libraries. It still comes with similar drawbacks as self-contained CoreCLR based library would though:

  • Debugging experience is reduced - in the NativeAOT case you can definitely debug it, but it looks like a C++ (or other native) code for the debugger.
  • Multiple GCs in one process - and all the potential issues which come with that. This should not be a functional problem, but could be a performance issue depending on the usage.

@govert
Copy link

govert commented Jan 20, 2023

Can you perhaps expand a bit or add a link about the "Multiple GCs in one process"?
I imagine having to support many tens of add-in libraries (built with NativeAOT) in a single Excel process. They can't use a shared runtime because .NET 6 might also be loaded in the process. Would this be OK, supposing one has enough memory?

@ThaDaVos
Copy link

Sadly, dotNET 7 NativeOAT doesn't support x86...

@vitek-karas
Copy link
Collaborator

Can you perhaps expand a bit or add a link about the "Multiple GCs in one process"

I don't think we have a document discussing this. @VSadov might know more about this - if it's something we would recommend in your case (10s of GCs in one process).

Note that if you wanted self-contained, then this would exist regardless if it's NativeAOT or not.

@VSadov
Copy link

VSadov commented Jan 21, 2023

I am not completely sure I understand the context here. The way NativeAOT runtime is structured should allow multiple dynamically loaded libraries in a process each with its own runtime and its own GC. It is not a common scenario, so there could be issues, but it should work.
When multiple NativeAOT libraries are linked into an app statically, they are linked with only one runtime library and thus share the runtime and GC.

@MichalStrehovsky would know what configurations would be more appropriate here.

@ThaDaVos
Copy link

What I have done is used Fody with Fody.ILMerge - you'll end up with two DLLs - your normal dll and the NE one - for me, it works perfectly this way

@maximilien-noal
Copy link
Author

maximilien-noal commented Apr 27, 2024

Hi,

Any update on this perhaps ?

Also is dnne still considered experimental ?

Thank you !

@AaronRobinsonMSFT
Copy link
Owner

@maximilien-noal No updates on this issue. Since .NET 5 a bunch of things have happened in the hosting space so it might now be easier to make this possible in a supported manner. @elinor-fung, Are there officially supported options for loading an assembly from within a native binary? I'm not keen on reimplementing the single file experience outside of the .NET SDK, but I might be able to create some narrow scenario.

Also is dnne still considered experimental ?

It is experimental in the sense that it isn't supported officially by .NET and instead by me, one of the .NET runtime devs. It is also a relatively simple project that can be easily replicated by any one using official .NET 5+ APIs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests