publish self-contained PublishSingleFile Could not load file or assembly 'netstandard

73 views
Skip to first unread message

Taylor Funk

unread,
Jul 16, 2021, 11:46:01 AM7/16/21
to tesseract-ocr
  • dotnet publish -c Release -r win-x64 -p:PublishSingleFile=true -p:PublishTrimmed=true --self-contained true
  • when publishing a single .exe in .net 3 I'm getting this error when I try to instantiate the engine
  • Could not load file or assembly 'netstandard, Version=2.0.0.0, Culture=neutral
  • var engine = new TesseractEngine(keyDir, item.lang, EngineMode.Default); works fine when i'm debugging, or if I click the non self contained exe file.
  • I don't know if setting the custom search willsolve this. still not working though
    var assembly = Assembly.GetEntryAssembly(); var loc = assembly.Location; var name = $"{assembly.GetName().Name}.dll"; loc = loc.Replace(name, ""); TesseractEnviornment.CustomSearchPath = loc;

Taylor Funk

unread,
Jul 22, 2021, 10:39:55 AM7/22/21
to tesseract-ocr
solved it. needed to exclude in the csproj the netstandard from the trim optimization

<TrimmerRootAssembly Include="netstandard" />

Reply all
Reply to author
Forward
0 new messages