Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Defining SQLCMD variables in the project prevents them from being set via environment variables #448

Open
MrazqRuby opened this issue Jul 12, 2023 · 0 comments

Comments

@MrazqRuby
Copy link

MrazqRuby commented Jul 12, 2023

It seems to me that defining the <SqlCmdVariable> ... </SqlCmdVariable> is actually worse than not defining it.

I am building a .dacpac with this SDK with a Post-Deploy script that uses variables like this:

IF (1 = ISNULL($(SQLCMD_DEPLOY_CONFIGS), 0))
BEGIN
# ...
END

I am not defining <SqlCmdVariable> ... </SqlCmdVariable> anywhere.

  1. Running sqlpackage.exe /a:Publish ... in a container where the SQLCMD_DEPLOY_CONFIGS environment variable is defined results in the value from the environment variable being replaced in the script.
  2. Running sqlpackage.exe /a:Publish ... /v:SQLCMD_DEPLOY_CONFIGS=0 also works, although it prints "The following SqlCmd variables are not defined in the target scripts: SQLCMD_DEPLOY_CONFIGS."

BUT

If I go and now define:

<SqlCmdVariable Include="SQLCMD_DEPLOY_CONFIGS">
		<!--Defines whether configuration scripts should be deployed: 0 - No, 1 - Yes-->
	<DefaultValue>$(SQLCMD_DEPLOY_CONFIGS)</DefaultValue>
	<Value>$(SQLCMD_DEPLOY_CONFIGS)</Value>
</SqlCmdVariable>

then the approach with the environment variable (1) no longer works. So to me it seems that it is worse to define the sqlcmd vars?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant