0

Is there a way to access the vaules in the Publish Profile in the proj-file, when publishing from VS?

I get no value when using "$(SqlCmdVar__3)".

< Message Text="$(SqlCmdVar__3)" Importance="high"/ >

I just get the default values when using "%(SqlCmdVariable.Value)".

< Message Text="%(SqlCmdVariable.Value)" Importance="high"/ >

The variable is in my included file (included from proejct-file, with a before-build target that is executed ok except for this issue):

 < SqlCmdVariable Include="TargetServerName">

      < DefaultValue>TestServer1< /DefaultValue>
        < Value>$(SqlCmdVar__3)< /Value>
      < /SqlCmdVariable >
Mohit Kanwar
  • 2,962
  • 7
  • 39
  • 59
SAS
  • 3,943
  • 2
  • 27
  • 48
  • Have you assigned a value to them when you edit the publish profile? You should be able to do so without too much trouble if they're already defined for the project. Once defined, they're used throughout the project in the $(MyVariable) format. – Peter Schott Apr 02 '15 at 15:48
  • I added explanation above, it is during BeforeBuild that the code is executed, so the default vaule would be fine to start with, if I could get it.. – SAS Apr 08 '15 at 12:26
  • I'm not sure it makes as much sense in that context. The "Build" puts together a dacpac with the model and pre/post script. It's not until you "Publish" that the variables make any sense. – Peter Schott Apr 08 '15 at 20:38
  • I Think you might be right, but I want some way of telling which publish profile was double-clicked to initiate the publish. – SAS Apr 09 '15 at 07:03
  • _That_ you should be able to get from a SQLCMD variable set in the Publish Profile. Of course, those could be overridden if someone uses the command line, but generally that would be good enough. We do something like that for our different environments. – Peter Schott Apr 09 '15 at 15:23

0 Answers0