Skip to content

Conversation

ErikEJ
Copy link
Contributor

@ErikEJ ErikEJ commented Oct 13, 2025

if metadata in the target database indicates that the database has already been deployed

fixes #860

Smoke tested with:

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();

Closes #860

PR Checklist

  • Created a feature/dev branch in your fork (vs. submitting directly from a commit on main)
  • Based off latest main branch of toolkit
  • PR doesn't include merge commits (always rebase on top of our main, if needed)
  • Tests for the changes have been added (for bug fixes / features) (if applicable)
  • Contains NO breaking changes
  • Every new API (including internal ones) has full XML docs
  • Code follows all style conventions

Other information

…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();
@Copilot Copilot AI review requested due to automatic review settings October 13, 2025 06:41
@ErikEJ ErikEJ requested a review from jmezach as a code owner October 13, 2025 06:41
Copy link
Contributor

@Copilot Copilot AI left a 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

@ErikEJ ErikEJ requested a review from Copilot October 13, 2025 07:23
Copy link
Contributor

@Copilot Copilot AI left a 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.

@ErikEJ
Copy link
Contributor Author

ErikEJ commented Oct 14, 2025

@jmezach Thanks for the review - I have attempted to address your comments

@ErikEJ ErikEJ requested review from Copilot and jmezach October 14, 2025 08:51
Copy link
Contributor

@Copilot Copilot AI left a 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.

@ErikEJ
Copy link
Contributor Author

ErikEJ commented Oct 20, 2025

@jmezach Ready for another review round?

@ErikEJ ErikEJ requested a review from Copilot October 20, 2025 12:18
Copy link
Contributor

@Copilot Copilot AI left a 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.

@ErikEJ ErikEJ requested a review from Copilot October 20, 2025 12:29
Copy link
Contributor

@Copilot Copilot AI left a 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.

@ErikEJ
Copy link
Contributor Author

ErikEJ commented Oct 21, 2025

@jmezach What's the verdict? 😄 - (I will of course follow up on any feedback realting to this)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SQL Projects: add ability to skip deployment if current package has already been deployed

2 participants