PortExtensionsAspire 134.2026.809.1615

dotnet add package PortExtensionsAspire --version 134.2026.809.1615
                    
NuGet\Install-Package PortExtensionsAspire -Version 134.2026.809.1615
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PortExtensionsAspire" Version="134.2026.809.1615" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PortExtensionsAspire" Version="134.2026.809.1615" />
                    
Directory.Packages.props
<PackageReference Include="PortExtensionsAspire" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add PortExtensionsAspire --version 134.2026.809.1615
                    
#r "nuget: PortExtensionsAspire, 134.2026.809.1615"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package PortExtensionsAspire@134.2026.809.1615
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=PortExtensionsAspire&version=134.2026.809.1615
                    
Install as a Cake Addin
#tool nuget:?package=PortExtensionsAspire&version=134.2026.809.1615
                    
Install as a Cake Tool

PortExtensionsAspire

NuGet License: MIT

A .NET Aspire extension that assigns deterministic (repeatable) ports to named resources and exposes them as PORT_{name} environment variables to other resources in your distributed application.

Features

  • Computes a deterministic port for a given name (and optional tag) so the same name always maps to the same port across runs
  • Registers the computed ports on a dedicated PortResource so they are visible in the Aspire dashboard as environment variables
  • Injects the registered ports (PORT_{name}) into any other resource via WithPortReference

Requirements

  • .NET 10.0 or later
  • Aspire 13.0 or later

Installation

Install via NuGet:

 dotnet add package PortExtensionsAspire

Usage

var builder = DistributedApplication.CreateBuilder(args);
var ports = builder.AddPort()
    .WithDeterministicPortEnvironment("sqliteweb", "mongodb")
    .Construct();

builder.AddSqlite("sqlite")
    .WithSqliteWeb(c =>
    {
        c.WithHttpEndpoint(targetPort: 8080, name: "http", port: ports.Resource.GetDeterministicPort("sqliteweb"));
    });

builder.AddProject<Projects.ShowPort>("ShowPort")
    .WithPortReference(ports);

builder.Build().Run();

⚠️ Warning: ports are not guaranteed to be unique

GetDeterministicPort derives a port by hashing the given name (optionally combined with a tag) and reducing it into the UInt16 range. This makes the port repeatable across runs for the same name, but it does not guarantee uniqueness across different names: two different names can hash to the same port (a hash collision), which would result in two resources being assigned the same port. If you hit a collision, pick a different name/tag combination for one of the resources, or manually override the port.

Contributing

Contributions are welcome! Please open issues or submit pull requests via GitHub.

License

This project is licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
134.2026.809.1615 91 8/9/2026