3F / DllExport

.NET DllExport with .NET Core support (aka 3F/DllExport aka DllExport.bat)
MIT License
937 stars 131 forks source link

Can't publish C# DLL on .NETCore #169

Open jplgarcia opened 3 years ago

jplgarcia commented 3 years ago

Steps to reproduce:

Information from Data tab or log data:

Every time I try to publish my DLL by right clicking and hitting publish I set target to my local folder configuration release, target framework .netcoreapp3.0 target runtime win-x64

The build and rebuild work fine but whenI publish I receive the following message " Publishing has encountered an error. Publishing has failed

A Diagnostic log has been written to the following location: "c:\User.....\AppData\Local\Temp\filename.tmp" "

Checking the file I receive an error that does not help very much:

2020-0

8-24 1:20:00 PM System.AggregateException: One or more errors occurred. ---> System.Exception: Publishing failed. --- End of inner exception stack trace --- at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) at Microsoft.Publish.Framework.Model.DefaultPublishSteps.<>c__DisplayClass26_0.b2() at System.Threading.Tasks.Task`1.InnerInvoke() at System.Threading.Tasks.Task.Execute() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Publish.Framework.Model.DefaultPublishSteps.d23.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Publish.Framework.ViewModel.ProfileSelectorViewModel.d__202.MoveNext() ---> (Inner Exception #0) System.Exception: Publishing failed.<---

System.Exception: Publishing failed.

===================

My code is no more than the following class:

using System; using System.Runtime.InteropServices;

namespace ClassLibrary2 { public class Class1 { [DllExport("Add2", CallingConvention.Cdecl)] public static int testAdd(int a, int b) { return a + b; }

    [DllExport("Say2", CallingConvention.Cdecl)]
    public static void sayWhatever()
    {
        Console.WriteLine("it workss");
    }
}

}

3F commented 3 years ago

Please follow our issue template and attach full information from the Data tab.

But I think you're just trying combine mentioned win-x64 runtime for x86+x64 configuration, that's incorrect. Check this out and reconfigure for x64.

mikasoukhov commented 3 years ago

Did you handle the issue like describe here https://github.com/dotnet/runtime/issues/33590 ?

Seems for .NET Core dll injection is not supported anymore.

supermartzin commented 3 years ago

Hi!

I have the exact same issue publishing a simple DllExport project targeted for .NET Core 3.1.

I've created simple .NET Core Class Library project, added most recent DllExport package from NuGet, configured the project for x86 (using workaround from #175) and when trying to publish the project, I get the same issue as stated above with the following error in the Output log:

Build started...
1>------ Build started: Project: DllExportTest, Configuration: Release x86 ------
1>DllExportTest -> [...]\DllExportTest\bin\x86\Release\netcoreapp3.1\win-x86\DllExportTest.dll
2>------ Publish started: Project: DllExportTest, Configuration: Release x86 ------
2>Determining projects to restore...
2>Restored [...]\DllExportTest\DllExportTest.csproj (in 291 ms).
2>DllExportTest -> [...]\DllExportTest\bin\x86\Release\netcoreapp3.1\win-x86\DllExportTest.dll
2>The file '[...]\DllExportTest\bin\x86\Release\netcoreapp3.1\win-x86\DllExportTest.pdb' to be packed was not found on disk.
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Publish: 0 succeeded, 1 failed, 0 skipped ==========

Project builds without any issue but publish fails every time, tried also changing parameters with no luck.

I'm attaching the whole sample project if it helps. DllExportTest.zip

Thanks! ✌

mikasoukhov commented 3 years ago

Not sure what happened, but .NET Core version does not work properly. Manual conversion via NDDE works, but it generates separate unmanaged dll.

3F commented 3 years ago

@supermartzin,

... pdb to be packed was not found on disk.

Your problem seems a bit different comparing this issue. Could you please open a new one. Thanks!

@mikasoukhov,

Seems for .NET Core dll injection is not supported anymore.

Make sure you're using my custom IL assembler together with rebasing (see related options) // #123 I can't say anything else without requested information.

mikasoukhov commented 3 years ago

I use Nuget package.

mikasoukhov commented 3 years ago

Think the reason was described here https://github.com/3F/DllExport/issues/175

Now no official instruction works with VS. Neither bat, no Nuget. Maybe someone will publish a quick solution or update the instruction. New projects for .NET Core is fully unsupportable )

CodingMadness commented 2 years ago

Is this closed by now?