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)
3 Answers 3
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.
- 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)
-
I have this issue, not all variables get in the sqlproj file. What did you do to fix that ? MAnually modify the sqlproj ?stetou– stetou2024年09月13日 19:52:09 +00:00Commented Sep 13, 2024 at 19:52
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.