Skip to main content

NuGet Dependencies

RevitDevTool supports NuGet references for C# scripts, F# scripts, and compiled .NET projects. This page is the shared guide for resolving packages, keeping host API references aligned, and diagnosing restore problems.

Where NuGet applies​

WorkflowSyntax or sourceBest use
C# script#r "nuget: Package, Version"Add a library to a .csx without creating a project
F# script#r "nuget: Package, Version"Reference libraries from an .fsx script
.NET assemblyProject PackageReferenceBuild a repeatable add-in or command assembly

Python dependencies use PEP 723 metadata and PyPI/conda-forge instead. See Modern Python Scripting.

C# and F# scripts​

Declare the package directly in the script:

#r "nuget: Humanizer, 2.14.1"
#r "nuget: MathNet.Numerics, 5.0.0"

The shared resolver restores packages under %APPDATA%\RevitDevTool\nuget. Keep versions explicit while debugging or sharing a script so another machine resolves the same dependency graph.

Compiled assemblies​

Use normal project references and target the Autodesk year you are building for:

<ItemGroup>
<PackageReference Include="Your.Package" Version="1.2.3" />
</ItemGroup>

Autodesk Revit API assemblies are compile-time references, not NuGet packages managed by the script resolver. Align the API reference, target framework, and host year before investigating package errors.

Resolution rules​

  • Pin versions for reproducible commands and examples.
  • Prefer packages compatible with the host target framework.
  • Avoid bringing a second copy of an assembly already loaded by the Autodesk host.
  • Keep transitive dependencies compatible with the host's loaded versions.
  • Re-run the command after changing a package declaration so the resolver can rebuild its cache.

Troubleshooting​

SymptomCheck
Package cannot be foundVerify the package id, version, network access, and configured feeds
Compile reports duplicate types or assembliesRemove a conflicting package or align it with the host-loaded version
Script works in one host year onlyCheck the Autodesk API references and target framework
Breakpoints do not bind after restoreKeep the original source path and attach the debugger to the host process

For debugging across C# scripts, F# scripts, .NET assemblies, and CPython, see Attach Debugger.