From 795c1d7f0fe04c7099f140f6ec040029432a6078 Mon Sep 17 00:00:00 2001 From: Jonathan Mezach Date: Thu, 2 Jan 2025 10:12:01 +0100 Subject: [PATCH 1/7] Update hosting-sql-database-projects.md Add example of deploying a NuGet package using the new support in 9.2.0. --- .../hosting-sql-database-projects.md | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/docs/community-toolkit/hosting-sql-database-projects.md b/docs/community-toolkit/hosting-sql-database-projects.md index 3d1bfe8cc6..8fbb04f4c3 100644 --- a/docs/community-toolkit/hosting-sql-database-projects.md +++ b/docs/community-toolkit/hosting-sql-database-projects.md @@ -63,6 +63,35 @@ builder.AddSqlProject("mysqlproj") Now when you run your .NET Aspire app host project you see the SQL Database Project being published to the specified SQL Server. +## NuGet Package support + +Starting with version 9.2.0 we now support deploying databases from referenced NuGet packages, such as those produced by [📦 MSBuild.Sdk.SqlProj](https://www.nuget.org/packages/MSBuild.Sdk.SqlProj) or [📦 Microsoft.Build.Sql](https://www.nuget.org/packages/Microsoft.Build.Sql). To use this, first add the NuGet package to your Aspire app host project, for example: + +```dotnetcli +dotnet add package ErikEJ.Dacpac.Chinook +``` + +Next, edit your project file to set the `IsAspirePackageResource` flag to `True` for the `PackageReference` you've just added, so for example: + +```xml + +``` + +Finally add the package as a resource to your .NET Aspire AppHost: + +```csharp +var builder = DistributedApplication.CreateBuilder(args); + +var sql = builder.AddSqlServer("sql") + .AddDatabase("test"); + +builder.AddSqlPackage("chinook") + .WithReference(sql); +``` + +> [!NOTE] +> By default the `.dacpac` is expected to be located under `tools/.dacpac`, so in this example `tools/ErikEJ.Dacpac.Chinook.dacpac`. If for whatever reason the `.dacpac` is under a different path within the package you can use `WithDacpac("relative/path/to/some.dacpac")` to specify a path relative to the root of the package. + ### Local .dacpac file support If you are sourcing your _.dacpac_ file from somewhere other than a project reference, you can also specify the path to the _.dacpac_ file directly: From ac1d539182e2d8a62bf4ee19a4123840226ebcb5 Mon Sep 17 00:00:00 2001 From: Jonathan Mezach Date: Fri, 3 Jan 2025 08:33:03 +0100 Subject: [PATCH 2/7] Update docs/community-toolkit/hosting-sql-database-projects.md Co-authored-by: David Pine --- docs/community-toolkit/hosting-sql-database-projects.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/community-toolkit/hosting-sql-database-projects.md b/docs/community-toolkit/hosting-sql-database-projects.md index 8fbb04f4c3..e95f780aed 100644 --- a/docs/community-toolkit/hosting-sql-database-projects.md +++ b/docs/community-toolkit/hosting-sql-database-projects.md @@ -65,7 +65,7 @@ Now when you run your .NET Aspire app host project you see the SQL Database Proj ## NuGet Package support -Starting with version 9.2.0 we now support deploying databases from referenced NuGet packages, such as those produced by [📦 MSBuild.Sdk.SqlProj](https://www.nuget.org/packages/MSBuild.Sdk.SqlProj) or [📦 Microsoft.Build.Sql](https://www.nuget.org/packages/Microsoft.Build.Sql). To use this, first add the NuGet package to your Aspire app host project, for example: +Starting with version 9.2.0, you can deploy databases from referenced NuGet packages, such as those produced by [📦 MSBuild.Sdk.SqlProj](https://www.nuget.org/packages/MSBuild.Sdk.SqlProj) or [📦 Microsoft.Build.Sql](https://www.nuget.org/packages/Microsoft.Build.Sql). To deploy, add the NuGet package to your Aspire app host project, for example: ```dotnetcli dotnet add package ErikEJ.Dacpac.Chinook From cb2428639df16f5faabddc49134406a429f42a26 Mon Sep 17 00:00:00 2001 From: Jonathan Mezach Date: Fri, 3 Jan 2025 08:33:23 +0100 Subject: [PATCH 3/7] Update docs/community-toolkit/hosting-sql-database-projects.md Co-authored-by: David Pine --- docs/community-toolkit/hosting-sql-database-projects.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/community-toolkit/hosting-sql-database-projects.md b/docs/community-toolkit/hosting-sql-database-projects.md index e95f780aed..a7983e2738 100644 --- a/docs/community-toolkit/hosting-sql-database-projects.md +++ b/docs/community-toolkit/hosting-sql-database-projects.md @@ -74,7 +74,8 @@ dotnet add package ErikEJ.Dacpac.Chinook Next, edit your project file to set the `IsAspirePackageResource` flag to `True` for the `PackageReference` you've just added, so for example: ```xml - + ``` Finally add the package as a resource to your .NET Aspire AppHost: From ab66f91a07e8c29047ca1345e4b407a9e1b5b466 Mon Sep 17 00:00:00 2001 From: Jonathan Mezach Date: Fri, 3 Jan 2025 08:33:47 +0100 Subject: [PATCH 4/7] Update docs/community-toolkit/hosting-sql-database-projects.md Co-authored-by: David Pine --- docs/community-toolkit/hosting-sql-database-projects.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/community-toolkit/hosting-sql-database-projects.md b/docs/community-toolkit/hosting-sql-database-projects.md index a7983e2738..d264b0b760 100644 --- a/docs/community-toolkit/hosting-sql-database-projects.md +++ b/docs/community-toolkit/hosting-sql-database-projects.md @@ -71,7 +71,7 @@ Starting with version 9.2.0, you can deploy databases from referenced NuGet pack dotnet add package ErikEJ.Dacpac.Chinook ``` -Next, edit your project file to set the `IsAspirePackageResource` flag to `True` for the `PackageReference` you've just added, so for example: +Next, edit your project file to set the `IsAspirePackageResource` flag to `True` for the corresponding `PackageReference`, as shown in the following example: ```xml Date: Fri, 3 Jan 2025 08:33:59 +0100 Subject: [PATCH 5/7] Update docs/community-toolkit/hosting-sql-database-projects.md Co-authored-by: David Pine --- docs/community-toolkit/hosting-sql-database-projects.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/community-toolkit/hosting-sql-database-projects.md b/docs/community-toolkit/hosting-sql-database-projects.md index d264b0b760..2da16b267a 100644 --- a/docs/community-toolkit/hosting-sql-database-projects.md +++ b/docs/community-toolkit/hosting-sql-database-projects.md @@ -78,7 +78,7 @@ Next, edit your project file to set the `IsAspirePackageResource` flag to `True` IsAspirePackageResource="True" /> ``` -Finally add the package as a resource to your .NET Aspire AppHost: +Finally, add the package as a resource to your app model: ```csharp var builder = DistributedApplication.CreateBuilder(args); From e25d851544f5913e58fd7d37afa396c106efce87 Mon Sep 17 00:00:00 2001 From: Jonathan Mezach Date: Fri, 3 Jan 2025 08:34:33 +0100 Subject: [PATCH 6/7] Update docs/community-toolkit/hosting-sql-database-projects.md Co-authored-by: David Pine --- docs/community-toolkit/hosting-sql-database-projects.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/community-toolkit/hosting-sql-database-projects.md b/docs/community-toolkit/hosting-sql-database-projects.md index 2da16b267a..f172a5572d 100644 --- a/docs/community-toolkit/hosting-sql-database-projects.md +++ b/docs/community-toolkit/hosting-sql-database-projects.md @@ -91,7 +91,7 @@ builder.AddSqlPackage("chinook") ``` > [!NOTE] -> By default the `.dacpac` is expected to be located under `tools/.dacpac`, so in this example `tools/ErikEJ.Dacpac.Chinook.dacpac`. If for whatever reason the `.dacpac` is under a different path within the package you can use `WithDacpac("relative/path/to/some.dacpac")` to specify a path relative to the root of the package. +> By default, the _.dacpac_ is expected to be located under _tools/.dacpac_. In the preceding example, the _tools/ErikEJ.Dacpac.Chinook.dacpac_ path is expected. If for whatever reason the _.dacpac_ is under a different path within the package you can use `WithDacpac("relative/path/to/some.dacpac")` API to specify a path relative to the root of app host project directory. ### Local .dacpac file support From a9a24fefb865e9f03ff033eb0d66177caf033a65 Mon Sep 17 00:00:00 2001 From: David Pine Date: Fri, 3 Jan 2025 08:50:30 -0600 Subject: [PATCH 7/7] Update docs/community-toolkit/hosting-sql-database-projects.md --- docs/community-toolkit/hosting-sql-database-projects.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/community-toolkit/hosting-sql-database-projects.md b/docs/community-toolkit/hosting-sql-database-projects.md index f172a5572d..7758e3e8c5 100644 --- a/docs/community-toolkit/hosting-sql-database-projects.md +++ b/docs/community-toolkit/hosting-sql-database-projects.md @@ -91,7 +91,7 @@ builder.AddSqlPackage("chinook") ``` > [!NOTE] -> By default, the _.dacpac_ is expected to be located under _tools/.dacpac_. In the preceding example, the _tools/ErikEJ.Dacpac.Chinook.dacpac_ path is expected. If for whatever reason the _.dacpac_ is under a different path within the package you can use `WithDacpac("relative/path/to/some.dacpac")` API to specify a path relative to the root of app host project directory. +> By default, the _.dacpac_ is expected to be located under `tools/.dacpac`. In the preceding example, the _tools/ErikEJ.Dacpac.Chinook.dacpac_ path is expected. If for whatever reason the _.dacpac_ is under a different path within the package you can use `WithDacpac("relative/path/to/some.dacpac")` API to specify a path relative to the root of app host project directory. ### Local .dacpac file support