简体   繁体   English

dacpac - CLR 程序集引用路径问题

[英]dacpac - CLR assembly reference path issue

Following is the exact scenario in my database project, where I am creating dacpac to deploy databases on target SQL instance:以下是我的数据库项目中的确切场景,我正在创建 dacpac 以在目标 SQL 实例上部署数据库:

  • the database project is having a reference of CLR assembly.数据库项目有一个 CLR 程序集的引用。
  • TFS build server is used to build the project TFS 构建服务器用于构建项目
  • dacpac is getting created during TFS build process dacpac 在 TFS 构建过程中被创建

– when i try to run sqlpackage.exe to deploy the dacpac (generated in TFS build process) in my environment, I get an error saying – – 当我尝试运行 sqlpackage.exe 以在我的环境中部署 dacpac(在 TFS 构建过程中生成)时,我收到一条错误消息 –

*** No file was supplied for reference XXXX.XXXX.XXXX.dll; *** 没有提供参考 XXXX.XXXX.XXXX.dll 的文件; deployment might fail.部署可能会失败。 When C:\\Temp\\Dacpac_testing\\XXX.XXXXX.XXXX.dacpac was created, the original referenced file was located C:\\BUILDS\\1\\XXXX\\XXXX\\SRC\\XXXXXXXX\\ASSEMBLIES\\XXXX.XXXX.XXXX.dll创建 C:\\Temp\\Dacpac_testing\\XXX.XXXXX.XXXX.dacpac 时,原始引用文件位于 C:\\BUILDS\\1\\XXXX\\XXXX\\SRC\\XXXXXXXX\\ASSEMBLIES\\XXXX.XXXX.XXXX.dll

How can I create a dacpac to reference the path of CLR assembly on deployment environment (and not the one that was used at the time of building dacpac)如何创建一个 dacpac 来引用部署环境中 CLR 程序集的路径(而不是构建 dacpac 时使用的路径)

Any help on this will be much appreciated.对此的任何帮助将不胜感激。

Sorry I only picked on this thread now, but I had a similar issue.抱歉,我现在只选择了这个线程,但我遇到了类似的问题。 Open the references in the Sql Server project, go to the dll that you are referencing right click and select properties.打开Sql Server项目中的引用,到你引用的dll右击选择属性。

Change the following settings: Generate Sql Script: True Model Aware: True更改以下设置:生成 Sql 脚本:真模型感知:真

Select the relevant Permission set as required by the clr code.根据 clr 代码的要求选择相关的权限集。

I was able to solve this issue by including all the files in the bin/output folder that is built by the SSDT project on the machine that is deploying the dacpac.我能够通过在部署 dacpac 的机器上包含由 SSDT 项目构建的 bin/output 文件夹中的所有文件来解决此问题。 This folder includes all the referenced DLLs and DAPACs.此文件夹包含所有引用的 DLL 和 DAPAC。 I also included the publish.xml file and some sample SQLPackage cmd files in the build output to make it easy to deploy.我还在构建输出中包含了 publish.xml 文件和一些示例 SQLPackage cmd 文件,以便于部署。

I found the answer from a post by Richard Gavel in the SQL Server Data Tools forum.我从 SQL Server Data Tools 论坛中 Richard Gavel 的帖子中找到了答案。 https://social.msdn.microsoft.com/Forums/sqlserver/en-US/aba60b70-396f-4624-890c-015c1f2d68f7/dacpac-dependencies-for-sqlpackageexe?forum=ssdt https://social.msdn.microsoft.com/Forums/sqlserver/en-US/aba60b70-396f-4624-890c-015c1f2d68f7/dacpac-dependencies-for-sqlpackageexe?forum=ssdt

I don't know if this helps but I was having trouble running SqlPackage /Action:Script between my compiled DACPAC and an extracted DACPAC and got a similar error (An error occurred while adding references).我不知道这是否有帮助,但我在我编译的 DACPAC 和提取的 DACPAC 之间运行 SqlPackage /Action:Script 时遇到了问题,并得到了类似的错误(添加引用时发生错误)。 I resolved it by copying all the DACPACS from the \\bin\\debug directory of my DACPAC (it has about references to 15 other database projects plus master and msdb).我通过从我的 DACPAC 的 \\bin\\debug 目录中复制所有 DPACACS 来解决它(它大约引用了 15 个其他数据库项目以及 master 和 msdb)。 After that, it worked.在那之后,它起作用了。 So it seems that in looking for references, it will check the directory first (I don't know if it was looking specifically at the current directory or the one the root DACPAC was in because those were one and the same).因此,在查找引用时,它似乎会首先检查目录(我不知道它是专门查看当前目录还是根 DACPAC 所在的目录,因为它们是相同的)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM