TransWikia.com

SqlPackage does not pick up variables from profile

Database Administrators Asked by THX-1138 on December 24, 2021

I want to upgrade a database using .dacpac and sqlpackage.exe

here is how I run sqlpackage:

SqlPackage.exe
    /Action:Publish
    /SourceFile:"my.dacpac"
    /Profile:"myprofile.publish.xml"

The error I get is:

* The following SqlCmd variables are not defined in the target scripts: foo.

I have verified that myprofile.publish.xml file does contain that var:

<ItemGroup>
  <SqlCmdVariable Include="foo">
    <Value>bclocal</Value>
  </SqlCmdVariable>

I also verified that project that creates dacpac does publish successfully from within visual studio using myprofile.publish.xml

What else could I be missing?

(I’m using SQL Server 2012)

3 Answers

You might have wrong dacpac. For example, you might extracted the dacpac from the database and this dacpac doesn't have any information about variables already. You can rename dacpac as *.zip and make sure that model.xml has your variables.

Answered by Dmitrij Kultasev on December 24, 2021

  • Open Visual Studio
  • Right click on your Database project
  • Open SQLCMD Variables page on the left side
  • Check if you have $(foo) defined in that variable list

I had the same issue the "missing" variables were defined in the publish.xml but I still received the same message. Then I browsed the .sqlproj file and I saw that not all the variables are listed there.

(I used Visual Studio 2019)

Answered by luviktor on December 24, 2021

Look at the references in your database solution. You will probably see them there. You can use the SQLPackage Script action to see the variables actually included in your dacpac.

Answered by Eric on December 24, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP