Skip to content
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

Missing references in SQLpackage contributor extension (DeploymentPlanModifier) #486

Open
BarrydeBoerUMCG opened this issue Sep 5, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@BarrydeBoerUMCG
Copy link

BarrydeBoerUMCG commented Sep 5, 2024

  • SqlPackage or DacFx Version: 16.0.6296
  • .NET Framework (Windows-only) or .NET Core: 4.8.
  • Environment (local platform and source/target platforms): windows server 2022

We created a sqlpackage contributor extension (DeploymentPlanModifier) to filter objects during the deployment of a dacpac.
On our development environment (with VS2022 installed) this works fine.

Steps to Reproduce:

  1. We copied the signed dll and pdb from our VS2022 project to the extensions folder of sqlpackage (C:\Program Files\Microsoft SQL Server\160\DAC\bin\Extensions) to the remote machine
  2. Verified that these files are unblocked
  3. Added 'AdditionalDeploymentContributors' argument to sqlpackage.exe to include the extension
  4. Run the deployment in a Devops Release pipeline, calling sqlpackage on the remote machine

We get a ReflectionTypeLoadException, probably indicating a missing reference!?

SafeDirectoryCatalog: Extensibility failed to load DLL 'C:\Program Files\Microsoft SQL Server\160\DAC\bin\Extensions\ContributorSubfolder\OurContributor.dll' due to an exception System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. 
   at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module) 
   at System.Reflection.Assembly.GetTypes() 
   at System.ComponentModel.Composition.Hosting.AssemblyCatalog.get_InnerCatalog() 
   at System.ComponentModel.Composition.Hosting.AssemblyCatalog.GetEnumerator() 
   at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source) 
   at Microsoft.SqlServer.Dac.Extensibility.DacExtensionHelper.TryLoadAssemblyCatalog(String file, ComposablePartCatalog& catalog)

Can anyone give an indication on how to solve this issue??

Did this occur in prior versions? If not - which version(s) did it work in?

(DacFx/SqlPackage/SSMS/Azure Data Studio)

@BarrydeBoerUMCG BarrydeBoerUMCG added the bug Something isn't working label Sep 5, 2024
@dzsquared
Copy link
Contributor

Interesting. Is the version of SqlPackage in your development environment (from Visual Studio 2022) the same as SqlPackage in your deployment environment? Ideally, they're both 162.x but validating that they're the same helps narrow down the reproducibility.
@zijchen for assembly loading expertise

@BarrydeBoerUMCG
Copy link
Author

On the environment it does work, sqlpackage version 16.1.6374.0 is installed.
Where it doesn't work, version 16.0.6296
Comparing the 2 enviroments it looks al the same to us; .Net 4.8 installed (created the contributor in this version), sqlpackage and the dll installed in the exact same place (C:\Program Files\Microsoft SQL Server\160\DAC\bin\Extensions\SubFolder\OurContributor.dll), except for the version of sqlpackage...

@dzsquared
Copy link
Contributor

oh, well that's good news! it not working with Sqlpackage from 2022 (16.0.6296 - https://learn.microsoft.com/en-us/sql/tools/sqlpackage/release-notes-sqlpackage?view=sql-server-ver16#192-sqlpackage) means that you likely will be sorted out by updating your deployment environment.

now might be a good time to move over to the sqlpackage dotnet tool, but if not there's still a bunch of ways to install - https://learn.microsoft.com/en-us/sql/tools/sqlpackage/sqlpackage-download?view=sql-server-ver16

(current sqlpackage version is 162.3.x)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants