Packaging a worker
WorkManager loads a worker from a nupkg: the worker DLL in lib/<tfm>/ and a
nuspec that declares its NuGet dependencies and the virtufin* load metadata.
Virtufin.Worker.DevKit ships the MSBuild target that writes it, so a worker
project needs no packaging code of its own.
Properties
| Property | Default | Nuspec element |
|---|---|---|
VirtufinPackageWorker |
false |
(turns the target on) |
VirtufinWorkerAbiVersion |
2 |
virtufinAbiVersion |
VirtufinWorkerEntryPoint |
Process |
virtufinEntryPoint |
VirtufinWorkerFreeResult |
FreeResult |
virtufinFreeResult |
VirtufinWorkerLibrary |
$(AssemblyName) |
virtufinLibrary |
VirtufinWorkerNupkgDir |
$(MSBuildProjectDirectory)/bin/worker-nupkg |
(output directory) |
PackageId, PackageVersion, Authors and Description fill the standard
nuspec elements. Every value is written literally and XML-escaped: the nuspec
is generated by MSBuild, never by a shell, so $, backticks, & and < in a
description are safe.
To ship another assembly from the publish output next to the worker DLL (for example a sibling worker project the worker wraps), add its basename:
<ItemGroup>
<VirtufinWorkerAssembly Include="SimulatedExecutorWorker" />
</ItemGroup>
To ship a file next to lib/ (a config schema, say), add it with the folder it
goes to in the nupkg:
<ItemGroup>
<VirtufinWorkerContent Include="../../schema/websocketfeed.config.schema.json" PackagePath="schema/" />
</ItemGroup>
What the nupkg contains
lib/<tfm>/<AssemblyName>.dlland anyVirtufinWorkerAssemblyDLLs, plus anyVirtufinWorkerContentfile under itsPackagePath. Nothing else is bundled.<PackageId>.nuspecwith one<dependencies>group for$(TargetFramework)that lists every directPackageReference, at its centralPackageVersion(or its ownVersion). A reference without a version fails the build. WorkManager resolves the transitive graph when it loads the worker, always at the latestVirtufin.*versions.
All files get a fixed mtime (1980-01-01) and are zipped with zip -X, so
rebuilding unchanged sources produces a byte-identical nupkg. The target needs
find, touch and zip on the path (Linux and macOS).
To turn it on for a worker, see Package a worker.