简体   繁体   English

如何避免 CI 中的 .dacpac 项目检查?

[英]How to avoid .dacpac project checks in CI?

I build my database project in CI using devenv.exe.我使用 devenv.exe 在 CI 中构建我的数据库项目。 All "Deploy" checkboxes in ConfigurationManager are disabled. ConfigurationManager 中的所有“部署”复选框都被禁用。 DeployToDatabase in sqlproj file is set to False. sqlproj 文件中的 DeployToDatabase 设置为 False。 I use devenv.exe like我使用 devenv.exe 之类的

devenv.exe "PathToSln\MySln.sln" /build /Release /Out "LogFile.log" 

And on each build I get error: "System-versioned current and history tables do not have matching schemas."在每次构建时,我都会收到错误消息:“系统版本控制的当前表和历史表没有匹配的模式。” I know what this error means, and I should live with it right now.我知道这个错误意味着什么,我现在应该接受它。 So, the questions is: how to remove Schema Validation in the devenv.exe through Command Line?那么,问题是:如何通过命令行删除devenv.exe中的Schema Validation?

Database projects always validate the schema prior to producing the dacpac file.数据库项目始终在生成 dacpac 文件之前验证模式。 There is no alternative to this.对此别无选择。 Also, the schema validation is unrelated to deployment -- it's checking whether the database defined by the project is internally consistent.此外,模式验证与部署无关——它检查项目定义的数据库是否在内部一致。

All of which is to say that you need to fix the error with your temporal tables.所有这些都是说您需要修复时态表的错误。 There are three things that I can think of that could be going on here:我能想到这里可能发生的三件事:

  • The version of SSDT installed on the machine is old and has a bug that causes this error to happen for most temporal table definitions.机器上安装的 SSDT 版本较旧,并且有一个 bug,导致大多数时态表定义发生此错误。 Ensure that your machine has the most recent version of SSDT.确保您的计算机具有最新版本的 SSDT。

  • Your project actually does contain an invalid temporal table definition.您的项目实际上确实包含无效的时态表定义。 This happens if you define both the current and the history table in the project, but the two tables have a different structure.如果您在项目中同时定义当前表和历史表,但这两个表具有不同的结构,则会发生这种情况。 Verify that your table schemas match or that your history table is implicitly defined (ie the history table name is specified, but the history table itself is not defined anywhere in the project with its own create table statement).验证您的表模式匹配或您的历史表是隐式定义的(即指定了历史表名称,但历史表本身没有在项目中的任何地方用它自己的 create table 语句定义)。

  • You're encountering a bug with temporal tables that hasn't been fixed yet.您遇到了一个尚未修复的时态表错误。 This can happen with implicit history table definitions.这可能发生在隐式历史表定义中。 Either switch to explicitly defined history tables, or work around the issue by closing VS and deleting the automatically generated DBMDL cache file that is found on disk beside the sqlproj file.要么切换到显式定义的历史表,要么通过关闭 VS 并删除在 sqlproj 文件旁边的磁盘上找到的自动生成的 DBMDL 缓存文件来解决该问题。

Custom Build Definitions should fix this.自定义构建定义应该解决这个问题。 Instead of building for /Release you could create a Build Definition that is called CI_Build and only have it build your code project and skip your database project.您可以创建一个名为 CI_Build 的构建定义,而不是为 /Release 构建,并且只让它构建您的代码项目并跳过您的数据库项目。

If you haven't created custom build definitions before, the drop down where you select Debug or Release you can select "Configuration Manager" and from there you can either turn off the build or your DB project (Un-check the corresponding Build column) or create a custom build by selecting "" from the Active solution configuration drop down.如果您之前没有创建自定义构建定义,您可以在选择调试或发布的下拉菜单中选择“配置管理器”,然后您可以关闭构建或您的数据库项目(取消选中相应的构建列)或通过从“活动解决方案配置”下拉列表中选择“”来创建自定义构建。 Then create a new one and configure what builds and what is skipped accordingly.然后创建一个新的并配置相应的构建和跳过的内容。

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

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