charlesw / tesseract

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

Only copy x64 DLL for project targeting x64 #492

Open sehcheese opened 5 years ago

sehcheese commented 5 years ago

I have a project that targets 64 bit which has Tesseract Nuget package installed. When I build it, both the 64 bit and 32 bit DLLs are copied to my bin directory. My publish package could be slimmer if it detected that my project targeted 64 bit and only copied those DLLs. Is there any way I can do this in the status quo? Or will this involve changes to this repository (and the consequential Nuget package)?

cgrard commented 4 years ago

I second this, and it's trivial as there's only a condition to add to Tesseract.targets:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <ItemGroup>
        <None Include="$(MSBuildThisFileDirectory)\..\x86\leptonica-1.78.0.dll" Condition="'$(Platform)' == 'x86'">
            <Link>x86\leptonica-1.78.0.dll</Link>
            <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
        </None>
        <None Include="$(MSBuildThisFileDirectory)\..\x86\tesseract41.dll" Condition="'$(Platform)' == 'x86'">
            <Link>x86\tesseract41.dll</Link>
            <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
        </None>
        <None Include="$(MSBuildThisFileDirectory)\..\x64\leptonica-1.78.0.dll" Condition="'$(Platform)' == 'x64'">
            <Link>x64\leptonica-1.78.0.dll</Link>
            <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
        </None>
        <None Include="$(MSBuildThisFileDirectory)\..\x64\tesseract41.dll" Condition="'$(Platform)' == 'x64'">
            <Link>x64\tesseract41.dll</Link>
            <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
        </None>
    </ItemGroup>
</Project>