Author Archives: Súper JMN

SelectMany working with large objects

This =>

void Main()
var selectMany = Enumerable.Range(1, 100)
.Select(i => new LargeObject(i))
.Select(o => Observable.FromAsync(() => DoSomethingAsync(o)))

// var selectMany = Enumerable.Range(1, 100)
// .ToObservable()
// .Select(i => Observable.Defer(() => Observable.Return(new LargeObject(i)))
// .SelectMany(o => Observable.FromAsync(() => DoSomethingAsync(o)))
// ).Merge(4);

selectMany.Subscribe(o => Console.WriteLine(o.Id));

NuGet package that copies files/folders to Output

You have the specific need: your NuGet package needs some native libs/files (not .NET assemblies) that need to place in the output folder.

For example, I have been using LEAD Tools to perform OCR to some images. The OCR engine needs a bunch of files to work (build and run, of course), so I created this structure inside my NuGet package:


Basically, if consists of a build folder (special folder) inside the package, with the file structure that you want to be copied into your output folder (where your executable files and/or libraries will be built).

And most importantly, it also needs to have a .targets file that is a special MSBuild file that will be interpreted each type you build your project.

In the snapshot above it’s listed as LeadTools.Ocr.AdvantageEngine-x86.targets

This file has to contain this script:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="">
    <NativeLibs Include="$(MSBuildThisFileDirectory)**\*.*" />
    <Content Include="@(NativeLibs)">

I’m not 100% sure, but I think this file should have the same name as your NuGet package (the Id of the package).

With both things, the files/folders inside the build folder and the targets file, you’re done 🙂

Installing a package like this in a project will modify your .csproj to include a special Import section like this:

  <Import Project="..\packages\LeadTools.Ocr.AdvantageEngine-x86.19.0.1\build\LeadTools.Ocr.AdvantageEngine-x86.targets" Condition="Exists('..\packages\LeadTools.Ocr.AdvantageEngine-x86.19.0.1\build\LeadTools.Ocr.AdvantageEngine-x86.targets')" />
  <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
      <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see The missing file is {0}.</ErrorText>
    <Error Condition="!Exists('..\packages\LeadTools.Ocr.AdvantageEngine-x86.19.0.1\build\LeadTools.Ocr.AdvantageEngine-x86.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\LeadTools.Ocr.AdvantageEngine-x86.19.0.1\build\LeadTools.Ocr.AdvantageEngine-x86.targets'))" />

Extracto de The Successful Bad Programmer

Cuando la ávida e incauta Pepita trató de desviar la atención de Muza para resolver el bug de una manera más que cuestionable, se oyó un desgarrador rugido que provenía del baño. Fue entonces cuando de un portazo la puerta se abrió y el temible Cronodogo from Cuernavilla se avalanzó sobre su víctima y de una certera cartokick le calló la puta boca mientras susurraba:

“shhhhh… tú a callar, censo. Realiza las lecturas obligatorias del Tema 5 al 7, reza 20 ‘cartos nuestros’, prónate 50 veces frente a The pragmatic programmer y ven a las 17:15 con las manos vueltas. Recibirás 80 varazos impregnados de Quina Santa Catalina. Esta es tu penitencia”

Cronodogo se retiró cual león alado del Tigris y unos nubarrones se cernieron sobre La Choza del Tío Mamert.