microsoft / microsoft/DacFx

SqlProj Build Fails When Deployment Contributor Is Required

Open
#341 0 comments 0 reactions 0 assignees View on GitHub
area: build sdk bug
Dominant language
C#
Stars
460
Forks
29
Avg merge
4d 9h
Merged PRs (30d)
7

Description

- SqlPackage or DacFx Version: SqlPackage version is not used during the build time or I'm not aware of that. In my opinion it loads assemblies through the MSBuild Tasks which are deployed via Microsoft.Build.Sql 0.1.12-preview SDK.
- .NET Framework (Windows-only) or .NET Core: dotnet core / net 6
- Environment (local platform and source/target platforms): windows / linux net6 build agent

I think, this bug report is different from what is reported about SQLPackage publish cannot load deployment contributors because this is happening during the build time of the project.
```
C:\Users\username\.nuget\packages\microsoft.build.sql\0.1.12-preview\tools\netstandard2.1\Microsoft.Data.Tools.Schema.SqlTasks.targets(542,5): Build error : Required contributor with id 'SampleDeploymentContribu
tor.SampleDeploymentContributor' could not be loaded. [C:\Users\username\Projects\externals\DacFx\samples\DeployToDatabaseFails\SampleDatabase\SampleDatabase.sqlproj]
```

**Steps to Reproduce:**

1. Create a new class library with a deployment contributor implementation, i.e. an empty one is good enough which logs a line.
2. Create a new SQLProj file from the template as per the guide in the documentation on this site.
3. Ensure the SqlProj contains the following lines `
$(DeploymentContributors);The.Id.Of.Deployment.Contributor.Here
`
4. Set on the project a Local SQL DB instance.
5. Build the SQLProj
The result with full repro build.ps1 is here: https://github.com/znamenap/DacFx/tree/DeploymentContributorFailsSqlBuild/samples/DeployToDatabaseFails

**Did this occur in prior versions? ** It did not occur in prior versions.
** If not - which version(s) did it work in?** It worked before migrating my projects to SDK-like project.

> dotnet --version 6.0.414
> MSBuild version 17.3.2+561848881 for .NET
> Microsoft.Build.Sql 0.1.12-preview

My opinionated requirement and suggestion to solve this:
* **Requirement**: need to specify the path to my/3rdparty contributors via an explicit path/folder only - at best addressable from NuGet package of the contributor referenced in the SQL Project as a build time dependency.
* **Suggestion**: make the static default value of the internal settings name DeploymentContributorPaths settable from the task as a mapped property value from SqlProjects.

Contributor guide

Open the contributing guide

Research direction

Start with Microsoft.Data.Tools.Schema.SqlTasks.targets around line 542 and the Microsoft.Build.Sql 0.1.12-preview build flow. Run the linked samples/DeployToDatabaseFails repro using build.ps1 and inspect how the SQLProj receives DeploymentContributors. Done means the SDK-style SQLProj builds successfully with a required third-party deployment contributor available from an explicit path or package dependency.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, sql
Domain
build-system, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.