Skip to content

NuGet & Assemblies

Tareq Imbasher edited this page May 20, 2024 · 4 revisions

NuGet

You can add a NuGet package using the Package Manager.

🖱️ To get to the Package Manager click the 🔧 icon (or press F4) to open your script's properties window then go to Packages.

The window is split into 3 columns:

  • The left side column is your local Package Cache. These are NuGet packages you have already downloaded and exist on your computer.
  • The middle column allows you to search and download new packages from the NuGet repository.
  • The right column shows you information about a selected NuGet package.

Package Cache

NetPad downloads and caches NuGet packages into a custom directory. The location of this directory can be configured in Settings > General > Folders > Package Cache. You can purge this directory from the Package Manager.

💡 Tip After adding a NuGet package, go to the References tab and select the package to easily add the namespaces you want to use in your script.

Adding NuGet Sources

NetPad will recognize additional NuGet sources added to your Nuget.Config file. There is no UI to manage these sources in NetPad so far, so you'll have to add them manually. More info

Assemblies

You can also reference and use your own assemblies.

🖱️ Click the 🔧 icon (or press F4) to open your script's properties window and then go to References. Here you can click the Browse button to select an assembly from your computer and then directly use it in your script.

If your assembly depends on other assemblies, NetPad will attempt to load the dependencies from the same directory as the selected target assembly. You can also add the dependencies directly in References.

Feel free to mix and match referencing NuGet and local assemblies.

InternalsVisibleTo

NetPad compiles your script into an assembly with the name "NetPadScript". To make the internals of your own assemblies visible to NetPad scripts add this attribute to your assembly:

[InternalsVisibleTo("NetPadScript")]