10

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>bc\local</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)

asked Jul 8, 2013 at 17:52

3 Answers 3

2

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 Jul 12, 2013 at 0:08
2
  • 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 Jul 24, 2020 at 8:07
1
  • I have this issue, not all variables get in the sqlproj file. What did you do to fix that ? MAnually modify the sqlproj ? Commented Sep 13, 2024 at 19:52
0

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 Dec 14, 2021 at 14:55

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.