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.
Opt in
Set VirtufinPackageWorker in the worker's csproj. dotnet publish then
writes <VirtufinWorkerNupkgDir>/<PackageId>.nupkg:
<PropertyGroup>
<AssemblyName>MyWorker</AssemblyName>
<PackageId>Virtufin.Worker.My</PackageId>
<PackageVersion>0.0.0-local</PackageVersion>
<Authors>Virtufin</Authors>
<Description>What the worker does.</Description>
<VirtufinPackageWorker>true</VirtufinPackageWorker>
</PropertyGroup>
The target comes in through the package's buildTransitive/ folder, so it is
there whether the worker references the DevKit directly or through a domain
devkit. Projects that don't opt in (devkits, tests, notebooks) are unaffected.
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>
What the nupkg contains
lib/<tfm>/<AssemblyName>.dlland anyVirtufinWorkerAssemblyDLLs. 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).