charlesw / tesseract

A .Net wrapper for tesseract-ocr
Apache License 2.0
2.28k stars 744 forks source link

Tesseract NuGet package - non-standard folders breaks tools such as LINQPad #484

Open albahari opened 5 years ago

albahari commented 5 years ago

In the Tesseract NuGet package, the native DLLs are in following folders:

\x64 \x86

Could they please be moved to the standard location? That is:

\runtimes\win-x64\native \runtimes\win-x86\native

This would enable Tesseract to work with tools such as LINQPad. (As it is, it can only work with MSBuild.)

Here's the documentation on naming folders in NuGet (jump to "Architecture-specific folders"): https://docs.microsoft.com/en-us/nuget/create-packages/supporting-multiple-target-frameworks.

And here's the complete list of RIDs: https://docs.microsoft.com/en-us/dotnet/core/rid-catalog

charlesw commented 5 years ago

Good idea, I didn't know about them. I'll have a look at updating tesseract in time for the next release.

ZinohJoe commented 3 years ago

Added this method to my LINQPad queries to allow InteropDotNet to find the native assemblies within the temporary folder LINQpad creates upon query execution.

Note that I'm on Windows and am still a beginner so I can't verify if it will work for everyone.

static void CopyTessLibraries(string tessVersion, string platform)
    {
        var destFolder = Path.Combine(Environment.CurrentDirectory,platform);

        Directory.CreateDirectory(destFolder);

        var tessNugetFolder = new LINQPad.ObjectModel.NuGetReference("Tesseract")
                                    .GetPackageFolders()
                                    .First(folderName => folderName.Contains($@"Tesseract\{tessVersion}"));

        var platformFiles = Directory.GetFiles(Path.Combine(tessNugetFolder,platform));
        foreach (var file in platformFiles)
        {
            var fileInfo = new FileInfo(file);
            var destFile = Path.Combine(destFolder, fileInfo.Name);
            if (!File.Exists(destFile))
            {
                fileInfo.CopyTo(destFile, true);
            }
        }
    }

2020-12-19_13-38-36