简体   繁体   中英

How to avoid .dacpac project checks in CI?

I build my database project in CI using devenv.exe. All "Deploy" checkboxes in ConfigurationManager are disabled. DeployToDatabase in sqlproj file is set to False. I use devenv.exe like

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?

Database projects always validate the schema prior to producing the dacpac file. 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. Ensure that your machine has the most recent version of 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).

  • 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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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