Reputation: 5277
I am getting the following exception during the build of my database projects.
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets(513,5): Error: MSB4018: The "SqlBuildTask" task failed unexpectedly.
14>Microsoft.Data.Tools.Schema.SchemaModel.ScriptCacheException: The cache identifier E:\Systems\MyProject\WorkingCopy-branch\source\Database.my_db_project\obj\debug.Deploy\ASMREXEXP.generated.sql does not exist.
The strange thing is that the build works fine on trunk, but fails with this exception on a feature branch.
Upvotes: 4
Views: 1661
Reputation: 5212
I just started to get this exact same error. The fact that we're both seeing mention of Schema.SchemaModel
suggests to me that we're both using some kind of text template strategy.
VS's build strategy for Text Template in the DB world requires that a dbmdl
file has already been created in order for them to run. This effectively means that you have to build the project twice; once to build the new dbmdl
file, then again to pick up the effects of haveing your text template dancing it.
What seems to happen - particularly when switching branches - is that you end up with an old dbmdl
file that is so different from what the templates are expecting, that what the templates try to do is odds with the "new" dbmdl
file that the build is trying to create - it's like trying to cherry-pick a template patch based on the old dbmdl
file and apply it to the new one - it doesn't work because the baselines are too far apart.
The solution is to find the dbmdl
file in your source tree and delete it. Then you can build to create a new dbmdl
file. the build will fail because the templates will fail, but you then build a second time and the template should pick up the new dbmdl
file and succeed.
Upvotes: 10