AaronRobinsonMSFT / DNNE

Prototype native exports for a .NET Assembly.
MIT License
394 stars 41 forks source link

Compilation failed when there is no exported method #155

Closed JeremyAnsel closed 1 year ago

JeremyAnsel commented 1 year ago

Hello, I've created a new Class Library project named DnneTest. Then I've added the DNNE nuget package. When I compile the project, I get this error:

Generated source file(s), obj\Debug\net6.0\dnne/DnneTest.g.c, not found. In order to generate source an export must exist. Create an export by adorning a function with UnmanagedCallersOnly. DnneTest C:\Users\jerem.nuget\packages\dnne\2.0.0\build\DNNE.targets 121

I was expecting the project to compile fine even when there is no exported method.

AaronRobinsonMSFT commented 1 year ago

I was expecting the project to compile fine even when there is no exported method.

Yep, this is by design. If the project isn't exporting a function then it shouldn't reference DNNE. Is there a scenario where this is desired?

AaronRobinsonMSFT commented 1 year ago

Another option is to set the following property in your project: <DnneBuildExports>false</DnneBuildExports>

AaronRobinsonMSFT commented 1 year ago

@JeremyAnsel I'm going to close this as "by-design". A goal of mine was to avoid people adding packages they are not using. If someone needs to reference this package and not create an export I would ask them to set in <DnneBuildExports>false</DnneBuildExports> their project.

JeremyAnsel commented 1 year ago

There is no scenario where I need it. It was just a question. IIRC when you add the package the compilation fails. Once you export a method the compilation succeeds. If you remove the method the compilation still succeeds.