Tamp.SqlCmd 0.1.0

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

Tamp.SqlCmd

Typed wrappers for the cross-platform sqlcmd CLI (Microsoft's go-sqlcmd). Run T-SQL scripts or inline queries against SQL Server and Azure SQL with typed connection settings, SqlCmd variable substitution, and Secret-tracked credentials.

Package Status
Tamp.SqlCmd 0.1.0 (initial)

Install

dotnet add package Tamp.SqlCmd

Multi-targets net8 / net9 / net10. Requires sqlcmd on PATH:

  • macOS: brew install sqlcmd
  • Linux: apt install sqlcmd (or download from the go-sqlcmd releases)
  • Windows: winget install Microsoft.Sqlcmd (or via SQL Server / Azure Data Studio installs)

Quick start — run migration scripts

using Tamp;
using Tamp.SqlCmd;

class Build : TampBuild
{
    public static int Main(string[] args) => Execute<Build>(args);

    [FromPath("sqlcmd")] readonly Tool SqlCmd = null!;
    [Parameter] readonly Secret DbPassword = null!;

    Target Migrate => _ => _.Executes(() => SqlCmd.RunScript(SqlCmd, s => s
        .SetServer("sql.example.com")
        .SetDatabase("AppDb")
        .SetUserName("deploy")
        .SetPassword(DbPassword)
        .SetTrustServerCertificate()
        .SetEncryption(SqlCmdEncryption.Mandatory)
        .AddInputFile("migrations/001_schema.sql")
        .AddInputFile("migrations/002_seed.sql")
        .SetVariable("DeployTag", "v1.2.3")
        .SetQueryTimeoutSeconds(600)));
}

Verb surface (v1)

Verb Wraps Required
RunScript sqlcmd -i file.sql [-i file2.sql ...] Server + at least one InputFile + an auth mode
RunInline sqlcmd -Q "SELECT ..." Server + Query + an auth mode

Authentication modes

Exactly one of these per invocation; the wrapper enforces it:

  • SQL auth.SetUserName(u).SetPassword(secret)-U u -P <secret>
  • Windows integrated.SetTrustedConnection()-E
  • Azure AD.SetAuthenticationMethod("ActiveDirectoryDefault")--authentication-method ActiveDirectoryDefault

Setting more than one throws InvalidOperationException. Setting UserName without Password (or vice versa) throws.

TLS knobs

Setter CLI
.SetTrustServerCertificate() -C
.SetEncryption(SqlCmdEncryption.Mandatory) -N mandatory
.SetEncryption(SqlCmdEncryption.Strict) -N strict

Other common knobs

  • SqlCmd variables.SetVariable(name, value)-v Name=Value (repeatable)
  • Exit on error.SetExitOnError()-b (default true; CI-friendly)
  • Query timeout.SetQueryTimeoutSeconds(300)-t 300
  • Output file.SetOutputFile(path)-o path
  • Disable variable substitution.SetDisableVariableSubstitution()-x (useful when scripts contain literal $(...) tokens)
  • Errors to stderr.SetErrorsToStderr(0) or (1)-r0 / -r1

Settings authoring — fluent or object-init

Both styles produce identical CommandPlans; fluent is canonical in docs.

Out of scope

Idempotency tracking (the __Migrations table pattern, ordering, dependency resolution) is intentionally adopter-side. This wrapper just executes — compose with your own migration discipline.

License

MIT — see LICENSE.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  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 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
0.1.0 38 5/22/2026