Use NuGet Packages in a Script v2

Add exact NuGet dependencies to a C# Script when its custom Method needs a library that is not part of the standard Runtime references.

Before you begin

Start with a C# Script that compiles without the package. Keep the Workflow Method signature limited to script-defined, standard .NET, and Flowgear types. A package-defined type can be used inside the Method body but cannot be exposed as a Workflow Parameter or Return.

Review the package's publisher, license, dependencies, supported frameworks, native assets, and security posture. Package code executes with the embedded script inside the Runtime process.

Add the dependency

  1. Select the C# Script Step.

  2. Open Script.NuGetPackages in the full editor.

  3. Enter one package per line in PackageId@exact.version form:

    Example.Package@1.2.3
    Another.Package@4.5.6
    
  4. Do not use ranges, wildcards, floating versions, leading spaces, or trailing spaces.

  5. Add the package namespace to Script.Content with an ordinary using directive.

  6. Use the package type inside the Method body.

  7. Resolve the C# and script diagnostics shown in Problems.

Verify the script

  1. Run a Debug execution. This acquires the package and compiles the complete source.
  2. Test representative success, failure, cancellation, and large-data paths.
  3. Inspect Workflow Logs and redact sensitive Workflow Properties where required.
  4. Save the Workflow to publish the compiled artifact to Test.
  5. Promote the reviewed revision through the remaining Environments.

When runtime dependencies are required, Flowgear publishes them beside the compiled Workflow in one bundle. Run Anywhere hosts must be able to execute the selected managed and native assets for their Runtime identifier.

Resolve package errors

Symptom What to check
SCRIPT_VALUE_ERROR Every non-empty line uses an exact PackageId@version with no padding.
SCRIPT_PACKAGE_ERROR reports not found Confirm the ID and exact version exist in the configured package source.
A dependency requires a newer version Remove an unnecessary root override or update the exact root to a compatible reviewed version.
Package is too large Choose a smaller dependency or move the capability into a governed published Node. Each package is limited to 10 MB compressed and 50 MB expanded.
Download times out Retry after verifying package-source and Cluster connectivity. Package acquisition has a one-minute limit, and a failed acquisition can remain cached for five minutes.
Type or namespace is missing during Preview Keep package types out of the public Method signature. Preview discovers the shape without package assemblies.
Duplicate dependency filename Select compatible packages whose runtime files do not have the same filename, or consolidate the implementation in a published Node.
Native library fails on a Cluster Confirm that the package supplies assets for that host's Runtime identifier and architecture.

Changing an exact version changes executable code. Repeat the source/dependency review, Debug test, save, and promotion process instead of treating the change as a metadata-only edit.

See also

See Embedded C# Scripts, Workflow Validation, and Workflow Artifacts.