Typed wrappers for the
sqlpackageCLI (Microsoft.SqlPackage):.dacpacPublish / Extract / Script for SQL Server and Azure SQL. Cross-platform —sqlpackageships as a dotnet tool and runs on Windows, macOS, and Linux.
| Package | Status |
|---|---|
Tamp.SqlPackage |
0.1.0 (initial) |
dotnet add package Tamp.SqlPackageMulti-targets net8 / net9 / net10. Requires sqlpackage on PATH (install with dotnet tool install -g Microsoft.SqlPackage).
using Tamp;
using Tamp.SqlPackage;
class Build : TampBuild
{
public static int Main(string[] args) => Execute<Build>(args);
[FromPath("sqlpackage")] readonly Tool SqlPackage = null!;
[Parameter] readonly Secret TargetConn = null!; // sourced from env or .tamp/secrets
Target Publish => _ => _.Executes(() => SqlPackage.Publish(SqlPackage, s => s
.SetSourceFile("artifacts/MyDb.dacpac")
.SetTargetConnectionString(TargetConn)
.SetProperty("BlockOnPossibleDataLoss", "false")));
}| Verb | Wraps | Required |
|---|---|---|
Publish |
/Action:Publish |
SourceFile, target (connection string OR server+database) |
Extract |
/Action:Extract |
TargetFile, source (connection string OR server+database) |
Script |
/Action:Script |
SourceFile, OutputPath, target (connection string OR server+database) |
Held for v2: Export, Import, DeployReport, DriftReport. File an issue if you need one.
- Connection vs. server/database split — supply either a full
Secretconnection string OR a plain server name + database name. Connection strings are always tracked asSecretand redacted from logs / plan emission. - Properties —
/p:Name=Valuerepeatable, set via.SetProperty(name, value). - SqlCmd variables —
/v:Name=Valuerepeatable, set via.SetVariable(name, value). - Access token —
/AccessToken:for Azure AD token-based auth, accepts aSecret. - Profile —
/Profile:publish.profile.xmlfor DAC Publish Profile. - Output controls —
OverwriteFiles,Quiet,Diagnostics,DiagnosticsFile.
Both styles produce identical CommandPlans. Fluent is canonical in docs / tamp init templates:
// Fluent
SqlPackage.Publish(SqlPackage, s => s
.SetSourceFile("a.dacpac")
.SetTargetConnectionString(conn));
// Object-init
SqlPackage.Publish(SqlPackage, new PublishSettings
{
SourceFile = "a.dacpac",
TargetConnectionString = conn,
});sqlpackage ships as the Microsoft.SqlPackage dotnet global tool and runs on Windows, macOS, and Linux. Argument format is Windows-style /Name:Value single-token (not POSIX --name value pairs); each flag is one process arg.
MIT — see LICENSE.