Skip to content

Commit

Permalink
Ensuring the right configuration is selected when loading the dacpack
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronpowell committed Feb 18, 2025
1 parent a8d1717 commit 01d7355
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Microsoft.Build.Evaluation;
using Microsoft.SqlServer.Dac;
using System.Reflection;

namespace Aspire.Hosting.ApplicationModel;

Expand All @@ -14,7 +15,14 @@ string IResourceWithDacpac.GetDacpacPath()
if (this.TryGetLastAnnotation<IProjectMetadata>(out var projectMetadata))
{
var projectPath = projectMetadata.ProjectPath;

var attr = this.GetType().Assembly.GetCustomAttribute<AssemblyConfigurationAttribute>();

using var projectCollection = new ProjectCollection();

if (attr is not null)
projectCollection.SetGlobalProperty("Configuration", attr.Configuration);

var project = projectCollection.LoadProject(projectPath);

// .sqlprojx has a SqlTargetPath property, so try that first
Expand Down

0 comments on commit 01d7355

Please sign in to comment.