SQL Server Data Tools: Error loading custom Deploy

2019-06-15 20:24发布

问题:

I need to intercept an SSDT build to modify the build script. I've followed the MSDN Deployment Plan Modifier tutorial, but when I attempt to build the database project, I get the following error:

Required contributor with id 'MyDeploymentContributor.SqlRestartableScriptContributor'
could not be loaded.

I am using Visual Studio 2012 (Version 11.0.61219.00 Update 5) and SSDT Version 11.1.50730.0.

I signed the assembly but did not specify a password.

I've followed several solutions I've found online to no avail, including the following:

  1. Updating Visual Studio and SSDT;
  2. Copying MyDeploymentContributor.dll and MyDeploymentContributor.pdb to the following locations:

    1. C:\Program Files (x86)\Microsoft SQL Server\110\DAC\bin\Extensions
    2. C:\Program Files (x86)\Microsoft SQL Server\110\DAC\bin
    3. C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\120
    4. C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\120\Extensions
  3. Capturing an event log for SSDT and DacFx (following Kevin Cunnane's instructions at https://social.msdn.microsoft.com/Forums/en-US/5c84ab8e-b50b-4ecd-86da-866ac3bb2248/known-issue-with-ssdt-extensibility-in-current-release?forum=ssdt). Here are the results from the DacFx log:

    • Core Services: SafeDirectoryCatalog: Assembly C:\Program Files (x86)\Microsoft Visual Stusio 11.0\Common7\IDE\Extensions\Micrsoft\SQLDB\DAC\120\Extensions\MyDeploymentContributor.dll added
    • Core Services: Extension Lookup: directory C:\Program Files (x86)\Microsoft Visual Stusio 11.0\Common7\IDE\Extensions\Micrsoft\SQLDB\DAC\120\Extensions added to extension lookup path
    • Core Services: FilteringCompositionContainer: Looking up exports for Microsoft.SqlServer.Dac.Deployment.DeploymentPlanExecutor
    • Core Services: FilteringCompositionContainer: Changed part creation policy to NonShared
    • Core Services: FilteringCompositionContainer: Looking up exports for Microsoft.SqlServer.Dac.Deployment.DeploymentPlanModifier

There were no ContributorLoader messages. From this log, the contributor seems to be loading correctly. The SSDT log didn't contain any events that mentioned the contributor.

There are no required contributor arguments, so the DeploymentContributor node in my .sqlproj file looks like this:

<PropertyGroup>
    <DeploymentContributors>
        $(DeploymentContributors); MyDeploymentContributor.SqlRestartableScriptContributor
    </DeploymentContributors>
</PropertyGroup>

Any help is appreciated. Thanks!

回答1:

Thanks to Ed Elliot ( https://the.agilesql.club/Blogs/Ed-Elliott/About ), I was able to resolve this issue in my case.

I followed Ed's suggestions and it worked. I created a folder like C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\120\Extensions\[YourContributorName]\ and copied all the contents (including DLLs) from C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\120 to there.

In the contributor project, I referenced the DLLs inside C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\120\Extensions\[YourContributorName]\

Once the project was built successfully, I copied the contributor .dll and .pdb files to the following location:

C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\120\Extensions\[YourContributorName]\

Before, I was referencing the DLLs from C:\Program Files (x86)\Microsoft SQL Server\110\DAC\bin.

Hope this would help someone.