Introducing UnpackDacPac

A .NET Tool for Extracting DAC Packages

Published on Wednesday, 29 November 2023

If you work with SQL Server databases, you may have encountered DAC packages, or dacpacs, which are a way of packaging a database's schema and seed data for deployment or migration. Dacpacs are useful for deploying databases to different environments, such as development, testing, or production, but it's tooling comes with some limitations. For example, you cannot easily inspect the contents of a dacpac file without having a running instance of SQL Server.

That's why I created UnpackDacPac, a .NET tool that enables you to extract a dacpac file and generate a deployment script to a target folder without the need to deploy it to an actual database. A really useful for example when you need to debug a failed deployment or retrieve an old version of a SQL object from just a DevOps build artifact. UnpackDacPac is a cross-platform tool that runs on .NET SDK 6, 7, and 8 (If you don't have the .NET SDK installed, you can get it from here).


You can install UnpackDacPac as a global tool from the command line by typing:

dotnet tool install --global UnpackDacPac


The usage of UnpackDacPac is simple:

unpackdacpac unpack <dacPacPath> <outputPath> [OPTIONS]

For example, if you have a dacpac file named Source.dacpac and you want to extract it to a folder named TargetPath, you can run:

unpackdacpac unpack Source.dacpac TargetPath

This will create the following files in the TargetPath folder:

  • DacMetadata.xml: This file contains the metadata of the dacpac, such as the name, version, description, and dependencies of the database.
  • Deploy.sql: This file contains the generated deployment script that can be used to create or update a database from the dacpac.
  • model.sql: This file contains the formatted SQL code that defines the schema and data of the database.
  • model.xml: This file contains the XML representation of the database model.
  • Origin.xml: This file contains the origin information of the dacpac, such as the source server and database name.
  • postdeploy.sql: This file contains any post-deployment scripts that are included in the dacpac.

One of the features of UnpackDacPac is that you can exclude certain types of objects from the generated deployment script by using the --deploy-script-exclude-object-type parameter. For example, if you want to exclude users, logins, and role memberships from the deployment script, you can run:

unpackdacpac unpack Source.dacpac TargetPath --deploy-script-exclude-object-type Users --deploy-script-exclude-object-type Logins --deploy-script-exclude-object-type RoleMembership

This will generate a deployment script that does not contain statements related to users, logins, or role memberships.

Where to find UnpackDacPac?

UnpackDacPac is an open-source project under a permissive MIT license, the source can be found on GitHub and the NuGet package at

Feedback and suggestions

I hope you find UnpackDacPac useful and feel free to provide any feedback, suggestions, or pull requests.

Happy unpacking!