A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.microsoft.com/en-us/nuget/reference/extensibility/nuget-cross-platform-plugins below:

NuGet cross platform plugins | Microsoft Learn

In NuGet 4.8+ support for cross platform plugins has been added. This was achieved with by building a new plugin extensibility model, that has to conform to a strict set of rules of operation. The plugins are self-contained executables (runnables in the .NET Core world), that the NuGet Clients launch in a separate process. This is a true write once, run everywhere plugin. It will work with all NuGet client tools. The plugins can be written in any programming language, but the easiest plugin development and installation experience will be with .NET. A versioned communication protocol between the NuGet Client and the plugin is defined. During the startup handshake, the 2 processes negotiate the protocol version.

How does it work

The high level workflow can be described as follows:

  1. NuGet discovers available plugins.
  2. When applicable, NuGet will iterate over the plugins in priority order and starts them one by one.
  3. NuGet will use the first plugin that can service the request.
  4. The plugins will be shut down when they are no longer needed.
General plugin requirements

The current protocol version is 2.0.0. Under this version, the requirements are as follows:

Plugins discovered from the PATH environment variable (for example, installed via dotnet tool) additionally must match the filename pattern nuget-plugin-*. The nuget-plugin- part must be written entirely in lowercase letters.

NuGet 6.12 (MSBuild 17.12, and .NET SDK 9.0.100) and earlier also required plugins to be Authenticode signed on Windows.

The technical specification is described in more detail in the following specs:

Client - Plugin interaction

NuGet client tools and the plugins communicate with JSON over standard streams (stdin, stdout, stderr). All data must be UTF-8 encoded. The plugins are launched with the argument "-Plugin". In case a user directly launches a plugin executable without this argument, the plugin can give an informative message instead of waiting for a protocol handshake. The protocol handshake timeout is 5 seconds. The plugin should complete the setup in as short of an amount as possible. NuGet client tools will query a plugin’s supported operations by passing in the service index for a NuGet source. A plugin may use the service index to check for the presence of supported service types.

The communication between the NuGet client tools and the plugin is bidirectional. Each request has a timeout of 5 seconds. If operations are supposed to take longer the respective process should send out a progress message to prevent the request from timing out. After 1 minute of inactivity a plugin is considered idle and is shut down.

Plugin installation and discovery

NuGet searches for plugins from a convention based directory structure, and scanning the PATH environment variable.

Convention based discovery

CI/CD scenarios and power users can use environment variables to override the behavior. When using environment variables, only absolute paths are allowed. Note that NUGET_NETFX_PLUGIN_PATHS and NUGET_NETCORE_PLUGIN_PATHS are only available with 5.3+ version of the NuGet tooling and later.

Framework Root discovery location Used by .NET Core %UserProfile%/.nuget/plugins/netcore dotnet CLI .NET Framework %UserProfile%/.nuget/plugins/netfx MSBuild, NuGet.exe, Visual Studio

Each plugin should be installed in its own folder. The plugin entry point will be the name of the installed folder, with the .dll extensions for .NET Core, and .exe extension for .NET Framework.

.nuget
    plugins
        netfx
            myPlugin
                myPlugin.exe
                nuget.protocol.dll
                ...
        netcore
            myPlugin
                myPlugin.dll
                nuget.protocol.dll
                ...
PATH discovery

Starting from NuGet 6.13, NuGet will search each directory provided in the PATH environment variable for files matching the pattern nuget-plugin-*. The pattern matching is case-sensitive, and nuget-plugin- must be written entirely in lowercase letters. On Windows the file must have an .exe or .bat extension. On Linux and Mac the file must have the executable bit set.

This allows NuGet plugins to be installed via dotnet tool commands, WinGet, a Linux distribution's package manager, or any other method that can put executables on the user's PATH. This also allows NuGet plugins to be written in any programming language (previously plugins for Linux and Mac must be written in .NET).

We recommend plugins are developed in .NET, so that you can use the NuGet.Protocol package to avoid needing to write the json RPC code, and to allow customers to discover your plugin via dotnet package search nuget-plugin.

Supported operations

Two operations are supported under the new plugin protocol.

Operation name Minimum protocol version Minimum NuGet client version Download Package 1.0.0 4.3.0 Authentication 2.0.0 4.8.0 Running plugins under the correct runtime

For the NuGet in dotnet.exe scenarios, plugins need to be able to execute under that specific runtime of the dotnet.exe. It's on the plugin provider and the consumer to make sure a compatible dotnet.exe/plugin combination is used. A potential issue could arise with the user-location plugins when for example, a dotnet.exe under the 2.0 runtime tries to use a plugin written for the 2.1 runtime.

Capabilities caching

The security verification and instantiation of the plugins is costly. The download operation happens way more frequently than the authentication operation, however the average NuGet user is only likely to have an authentication plugin. To improve the experience, NuGet will cache the operation claims for the given request. This cache is per plugin with the plugin key being the plugin path, and the expiration for this capabilities cache is 30 days.

The cache is located in %LocalAppData%/NuGet/plugins-cache and be overriden with the environment variable NUGET_PLUGINS_CACHE_PATH. To clear this cache, one can run the locals command with the plugins-cache option. The all locals option will now also delete the plugins cache.

Protocol messages index

Protocol Version 1.0.0 messages:

  1. Close

  2. Copy files in package

  3. Copy package file (.nupkg)

  4. Get credentials

  5. Get files in package

  6. Get operation claims

Note

This message has been updated in version 2.0.0. It is on the client to preserve backward compatibility.

  1. Get package hash

  2. Get package versions

  3. Get service index

  4. Handshake

  5. Initialize

  6. Log

  7. Monitor NuGet process exit

  8. Prefetch package

  9. Set credentials

  10. Set log level

Protocol Version 2.0.0 messages

  1. Get Operation Claims
  1. Get Authentication Credentials

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4