Install
No framework information available.
README
Dac Deploy Skip
Tool to determine if a deployment of a specific .dacpac file is required based on metadata present in the target database.
This can reduce your .dacpac deployment times significantly in scenarios you deploy the same .dacpac multiple times, e.g. in CI/CD pipelines.
Getting started
The tool runs on any system with .NET 10 or later installed.
Installing the tool
dotnet tool install -g ErikEJ.DacFX.DacDeploySkip
Basic usage
dacdeployskip check "<path to .dacpac>" "SQL Server connection string"
This command will return 0 if the .dacpac has already been deployed, otherwise 1.
dacdeployskip mark "<path to .dacpac>" "SQL Server connection string"
This command will add metadata to the target database to register the .dacpac as deployed.
You can use the optional -namekey parameter to use the name of the .dacpac file instead of the full path as key.
dacdeployskip mark "<path to .dacpac>" "SQL Server connection string" -namekey
Use -profile with both check and mark to include the deployment options and SQLCMD variables from the DacFX publish profile in the checksum:
dacdeployskip check "<path to .dacpac>" "SQL Server connection string" -profile "<path to .publish.xml>"
Pass the same publish profile to SqlPackage so the checksum represents the active deployment options. Target database and connection string values are excluded from the checksum.
Simpler usage in GitHub Actions
If you use GitHub Actions, you can call the repository action directly instead of installing the tool yourself. Here is a complete minimal workflow:
name: Deploy dacpac
on:
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Check if dacpac deployment is needed
id: dacdeployskip
uses: ErikEJ/DacDeploySkip@v1
with:
command: check
dacpac-path: ./Database/bin/Release/net10.0/Database.dacpac
connection-string: ${{ secrets.SQL_CONNECTION_STRING }}
- name: Install SqlPackage
if: steps.dacdeployskip.outputs.deployed != 'true'
run: dotnet tool install -g Microsoft.SqlPackage
- name: Deploy dacpac
if: steps.dacdeployskip.outputs.deployed != 'true'
run: sqlpackage /Action:Publish /SourceFile:"./Database/bin/Release/net10.0/Database.dacpac" /TargetConnectionString:"${{ secrets.SQL_CONNECTION_STRING }}"
- name: Mark dacpac as deployed
if: steps.dacdeployskip.outputs.deployed != 'true'
uses: ErikEJ/DacDeploySkip@v1
with:
command: mark
dacpac-path: ./Database/bin/Release/net10.0/Database.dacpac
connection-string: ${{ secrets.SQL_CONNECTION_STRING }}
You can optionally pass tool-version to pin the NuGet package version used by the action and publish-profile to include the deployment options in the checksum.
Sample usage in Azure DevOps pipeline
trigger:
- main
pool:
name: selfhosted
variables:
buildConfiguration: 'Release'
connectionString: 'Data Source=(localdb)\mssqllocaldb;Initial Catalog=TestBed;Integrated Security=true;Encrypt=false'
dacpacPath: '$(Build.SourcesDirectory)\Database\bin\Release\net10.0\Database.dacpac'
steps:
- powershell: |
dotnet tool install -g Microsoft.SqlPackage
dotnet tool install -g ErikEJ.DacFX.DacDeploySkip
dotnet build $(buildConfiguration)
dacdeployskip check "$(dacpacPath)" "$(connectionString)"
if (!$?)
{
sqlpackage /Action:Publish /SourceFile:"$(dacpacPath)" /TargetConnectionString:"$(connectionString)"
dacdeployskip mark "$(dacpacPath)" "$(connectionString)"
}
displayName: deploy dacpac if needed only
You can find a complete example here.
You can also use the tool to set a condition in your pipeline based on whether a deployment is needed or not. This can be useful if you use a task like SqlAzureDacpacDeployment or SqlDacpacDeploymentOnMachineGroup.
- powershell: |
dacdeployskip check "$(dacpacPath)" "$(ConnectionString)"
if (!$?)
{
Write-Host "##vso[task.setvariable variable=DeployDacPac;]$true"
}
else
{
Write-Host "##vso[task.setvariable variable=DeployDacPac;]$false"
}
displayName: check if dacpac deployment is needed
Then use the condition on subsequent tasks:
condition: and(succeeded(), eq(variables['DeployDacPac'], true))
Using multiple deployments against the same database
If you deploy multiple different .dacpac files against the same database, use the additional parameter /p:DropExtendedPropertiesNotInSource=False to avoid dropping the metadata added by this tool.
If you use a publish profile, you can add the same parameter there.
<DropExtendedPropertiesNotInSource>False</DropExtendedPropertiesNotInSource>
Changes from Previous Version
Adoption Assessment
A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.
Related Guides & Workflows
Learn how to evaluate, integrate, or audit this package in your .NET project.