简体   繁体   中英

Detect Visual studio build configuration in sql post deployment script

I have a VS solution whose purpose is to publish an sql database, via.sqlproj. It runs a post deployment script. I would like to set it up for multiple publish workflows. I want my sql post deployment script do do something like the following (pseudo-code):

if (VS build configuration is debug1)
BEGIN
  :r .\Debug1Setup.sql
END
else if (VS build configuration is debug2)
BEGIN
  :r .\Debug2Setup.sql
END

Is that possible?

You can probably leverage the post-build command system in VS for this; in your project properties, on the build events tab you can enter commands together with variables that are expanded by VS before the command runs. $(ConfigurationName) is populated with the name of the active configuration. See https://docs.microsoft.com/en-us/visualstudio/ide/reference/pre-build-event-post-build-event-command-line-dialog-box?view=vs-2019 for more information. Pre/post build are executed like normal DOS batch files; any commands that work in DOS also work in them.

在此处输入图像描述

If the commands you want to execute cannot (or should not) be put in a post build script, you could consider having a post build script that modifies some other file, passing in the build configuration - for example you could programmatically create a batch file that contains the active configuration upon every build, but only run that batch file some times

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