Skip to content

Add netstandard2.0 target for .NET Framework - #66

Merged
elbruno merged 5 commits into
elbruno:mainfrom
Laurianti:downloader-1.6.1
Nov 5, 2026
Merged

elbruno merged 5 commits into
elbruno:mainfrom
Laurianti:downloader-1.6.1

Conversation

@Laurianti

@Laurianti Laurianti commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Closes #65

Adds a netstandard2.0 target to the core package, so .NET Framework 4.6.2+ apps can install it, on x64 and ARM64. The other packages stay on net8.0 and net10.0.

Summary

  • Move to ElBruno.HuggingFace.Downloader 1.6.1, the first version with that target.
  • Add DownloadMissingFilesAsync in src/Shared, which keeps the behavior of 0.6.0 in the five downloaders. With the bump alone, EmbeddingGemma can't start from an empty cache and 7 tests fail.
  • Keep the new dependencies and Nullable=annotations on the new target only.
  • Copy onnxruntime.dll next to .NET Framework apps, from the Microsoft.ML.OnnxRuntime package NuGet resolved. Otherwise Windows can load another one and crash. Not when the app excludes those native assets or already copies one, as with DirectML.
  • Add a test-netframework job that runs the tests on net48 and that publish needs.
  • Fix three tests that weren't stable on Windows, because that job can stop a release.

Validation

  • With the real models: core tests 412/412 on net48, net8.0 and net10.0. The other test projects match main (4 SharedModelTests failures on both).
  • On the fork: test-netframework 370 passed, 42 skipped, 0 failed, also on Windows ARM64. The Linux steps of publish.yml pass.
  • Packed package on net48 (x64, AnyCPU, with DirectML): vectors within 5e-9 of net8.0. On the real 4.6.2 runtime: download, resume and the vectors of 4.8.

On net8.0 and net10.0, a cancelled download now resumes and the model directory gets a .hf.download.resolved.json file.

Limits: a 32-bit app fails at build with a message, because ONNX Runtime has no 32-bit library. The netstandard2.0 DLL is 440 KB, the others 91 KB.

Happy to split.

The downloader now refuses a directory whose metadata names another repository or an older commit, and asks the hub for the commit also when every file is there. EmbeddingGemma takes files from two repositories in one directory, and a cached model must also be completed after its repository has moved, so the model downloaders call it through DownloadMissingFilesAsync, which makes no request when every file is there and otherwise removes the metadata of the previous download.
ElBruno.LocalEmbeddings also builds for netstandard2.0, so .NET Framework 4.6.2+ apps can use it. The code paths that differ are under #if NETSTANDARD2_0 and the new settings and packages are in netstandard2.0-only sections of the project. A buildTransitive target copies the native libraries of ONNX Runtime next to .NET Framework applications, in the version NuGet resolved for the application, and stops the build of 32-bit ones. The tests also run on net48 on Windows, locally and in a new windows-latest job of the publish workflow.

That job can stop a release, so three tests that were not stable on Windows change. BatchEmbeddingTests read the progress reports as they are made: with Progress<T> they arrived out of order on .NET Framework, and the tests failed in 4 of 15 runs. TestDataFixture has one directory for each instance, as an instance can fail while another deletes a shared one. The cancellation test of CustomEmbedderTests has a delay of 60 s instead of 5 s, as a busy machine can run both timers late and together.
The native files now come from the folder of Microsoft.ML.OnnxRuntime in the assets file, so a version raised on Microsoft.ML.OnnxRuntime.Managed alone or a fallback folder no longer give the wrong files or none. They are not copied when the application excludes the native assets of Microsoft.ML.OnnxRuntime, or already copies a file with the same name, as onnxruntime.dll of Microsoft.ML.OnnxRuntime.DirectML.
The native files are now the RuntimeTargetsCopyLocalItems of Microsoft.ML.OnnxRuntime for the target framework, instead of the task ResolvePackageDependencies of the SDK. They follow the version, the IncludeAssets and ExcludeAssets of each target framework of the application, and a file with the same name of a referenced project or of another package stops the copy. When NuGet resolved them for another runtime, as the win-x86 that the SDK gives to an application without PlatformTarget, the folder is the one of the version of the managed assembly.
…ep the packages on one version

The target now runs before _CopyFilesMarkedCopyLocal, so GetCopyToOutputDirectoryItems also collects the items that targets add after the compilation. The README says to keep all the ElBruno.LocalEmbeddings packages on the same version, as they share ElBruno.HuggingFace.Downloader.
@elbruno
elbruno merged commit d02a28c into elbruno:main Nov 5, 2026
1 check passed
@Laurianti
Laurianti deleted the downloader-1.6.1 branch November 7, 2026 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support .NET Framework (netstandard2.0 target)

2 participants