X39.Aspire.Hosting.SMB 1.0.0.9

dotnet add package X39.Aspire.Hosting.SMB --version 1.0.0.9
                    
NuGet\Install-Package X39.Aspire.Hosting.SMB -Version 1.0.0.9
                    
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="X39.Aspire.Hosting.SMB" Version="1.0.0.9" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="X39.Aspire.Hosting.SMB" Version="1.0.0.9" />
                    
Directory.Packages.props
<PackageReference Include="X39.Aspire.Hosting.SMB" />
                    
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 X39.Aspire.Hosting.SMB --version 1.0.0.9
                    
#r "nuget: X39.Aspire.Hosting.SMB, 1.0.0.9"
                    
#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 X39.Aspire.Hosting.SMB@1.0.0.9
                    
#: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=X39.Aspire.Hosting.SMB&version=1.0.0.9
                    
Install as a Cake Addin
#tool nuget:?package=X39.Aspire.Hosting.SMB&version=1.0.0.9
                    
Install as a Cake Tool

X39.Aspire.Hosting.SMB library

Provides extension methods and resource definitions for a .NET Aspire AppHost to configure a SMB resource.

Getting started

Install the package

In your AppHost project, install the .NET Aspire SMB Hosting library with NuGet:

dotnet add package X39.Aspire.Hosting.SMB

Usage example

Then, in the AppHost.cs file of AppHost, add a SMB resource and consume the connection using the following methods:

var smbShare = builder.AddSmbShare("default-smb");

var myService = builder.AddProject<Projects.MyService>()
                       .WithReference(smbShare);

Usage note for Windows

Windows has some problems with accessing the SMB shares due to the Windows Explorer not supporting any port but 445 for SMB. There is no solution for that yet in the context of this library.

Advanced Configuration

Configuring a SMB Share

The AddSmbShare method provides several parameters to customize your SMB resource:

var smbShare = builder.AddSmbShare(
    name: "custom-smb",       // Resource name (required)
    port: 445,                // Custom port (optional, defaults to random)
    shareName: "MY_SHARE",    // Share name (optional, defaults to "SHARE")
    username: "user1",        // Username (optional, defaults to "ANON")
    password: "securepass"    // Password (optional, defaults to "ANON")
);

Binding a Local Folder

You can bind a local folder to the SMB share using the WithFolder extension method:

var smbShare = builder.AddSmbShare("data-share")
                     .WithFolder("/path/to/local/folder");

This mounts the specified local directory to the /storage path in the container, making it accessible through the SMB share.

Connection String Format

The SMB resource provides a connection string in the following format:

smb://{username}:{password}@{host}:{port}/{share}

This connection string is automatically passed to services that reference the SMB resource.

Health Checks

The library automatically configures health checks for the SMB resource, ensuring your application can monitor the availability of the SMB share.

Container Information

The SMB resource is containerized using the dockurr/samba:4.21 Docker image.

Available Extension Methods

  • AddSmbShare - Adds an SMB share resource to your distributed application
  • WithFolder - Binds a local folder to the SMB share

Resource Properties

The SmbResource class provides the following properties:

  • PrimaryEndpoint - Access to the primary TCP endpoint of the SMB server
  • ConnectionStringExpression - Expression that evaluates to the connection string

Feedback & contributing

https://github.com/X39/X39.Aspire.Hosting.SMB

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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
1.0.0.9 132 7/14/2025