-
Notifications
You must be signed in to change notification settings - Fork 128
Add ability to skip .dacpac deployment #896
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…icates that the database has already been deployed fixes CommunityToolkit#860 var builder = DistributedApplication.CreateBuilder(args); var server = builder.AddSqlServer("sql") .WithDataVolume("sampledata") .WithLifetime(ContainerLifetime.Persistent); var database = server.AddDatabase("TargetDatabase"); var sdkProject = builder.AddSqlProject<Projects.SdkProject>("sdk-project") .WithSkipWhenDeployed() .WithReference(database); builder.Build().Run();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request adds the ability to skip .dacpac deployment when metadata in the target database indicates that the database has already been deployed with the same content. This optimization is particularly useful for scenarios where SQL container databases are persisted to permanent disk, significantly improving startup times for .NET Aspire AppHost projects.
Key changes implemented:
- Added
WithSkipWhenDeployed()
extension method for SQL projects and packages to enable conditional deployment - Implemented checksum-based deployment detection using SQL Server extended properties to track deployed .dacpac files
- Enhanced the publishing service to check for existing deployments before attempting to deploy
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.
Show a summary per file
File | Description |
---|---|
tests/CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects.Tests/AddSqlProjectTests.cs |
Added test coverage for the new WithSkipWhenDeployed() functionality and service registration |
tests/CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects.Tests/AddSqlPackageTests.cs |
Added test coverage for skip deployment functionality and explicit start behavior for SQL packages |
src/CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects/SqlProjectPublishService.cs |
Enhanced publishing logic to check deployment status and conditionally skip deployment based on checksum comparison |
src/CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects/SqlProjectBuilderExtensions.cs |
Added WithSkipWhenDeployed() extension methods and registered the new deploy skipper service |
src/CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects/README.md |
Updated documentation with usage examples for the new skip deployment functionality |
src/CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects/IDacpacDeploySkipper.cs |
New interface defining the contract for checking and managing deployment skip logic |
src/CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects/DacpacSkipWhenDeployedAnnotation.cs |
New annotation class to mark resources for conditional deployment |
src/CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects/DacpacDeploySkipper.cs |
Implementation of deployment skip logic using SHA256 checksums and SQL Server extended properties |
examples/sql-database-projects/SdkProject/SdkProject.csproj |
Updated MSBuild.Sdk.SqlProj version from 3.0.0 to 3.2.0 |
tests/CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects.Tests/AddSqlPackageTests.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects/SqlProjectBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects/SqlProjectBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects/SqlProjectBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects/DacpacSkipWhenDeployedAnnotation.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
src/CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects/IDacpacDeploySkipper.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects/DacpacChecksumService.cs
Show resolved
Hide resolved
src/CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects/DacpacDeploySkipper.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects/DacpacDeploySkipper.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects/DacpacDeploySkipper.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects/DacpacDeploySkipper.cs
Outdated
Show resolved
Hide resolved
@jmezach Thanks for the review - I have attempted to address your comments |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
src/CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects/IDacpacChecksumService.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects/SqlProjectPublishService.cs
Outdated
Show resolved
Hide resolved
@jmezach Ready for another review round? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.
src/CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects/IDacpacChecksumService.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects/IDacpacChecksumService.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects/IDacpacChecksumService.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects/DacpacChecksumService.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects/DacpacChecksumService.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects/SqlProjectPublishService.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects/DacpacChecksumService.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects/DacpacChecksumService.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
src/CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects/DacpacChecksumService.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects/DacpacChecksumService.cs
Show resolved
Hide resolved
src/CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects/DacpacChecksumService.cs
Show resolved
Hide resolved
src/CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects/SqlProjectPublishService.cs
Show resolved
Hide resolved
@jmezach What's the verdict? 😄 - (I will of course follow up on any feedback realting to this) |
if metadata in the target database indicates that the database has already been deployed
fixes #860
Smoke tested with:
Closes #860
PR Checklist
Other information