1

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?

1 Answer 1

1

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://learn.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.

enter image description here

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.