Can output DACPAC path/filename be changed from TFS Build? RRS feed

  • Question

  • In our CI build, I am compiling a production branch of our database project and the current development branch.  In a step after the compile, I am comparing the two dbschema files (named the same but different folders) to create the delta script.
    (Here is the why if you want any background:

    I am able to accomplish this with database projects because the dbschema is left the “sources” folder.
      Copying file from "obj\Debug\MyProject.dbschema" to "C:\Builds\2\MyTeamProject\CI (Compile and Unit Test Only)\Binaries\MyProject.dbschema".
    The binaries folder only contains the development version because it was the last compiled.

    However, with SSDT projects, the DACPAC is not anywhere on the “sources” path so I don’t have a way to compare both versions.  I only have the last built DACPAC in the Binaries folder. 
      MyProject -> C:\Builds\5\MyTeamProject\CI (Compile and Unit Test Only)\Binaries\MyProject.dacpac
      Copying file from "obj\Debug\MyProject.dll" to "C:\Builds\5\MyTeamProject\CI (Compile and Unit Test Only)\Binaries\MyProject.dll".

    Does anyone know if there is a way to put or keep the two DACPAC files in separate folders or do a post step to rename the DACPAC files? I thought about modifying the outputdir but since both projects are named the same too, I would think they would still go to the same folder.  (I’m using VS 2012 but TFS 2010 on the server).



    blog -

    Tuesday, November 13, 2012 2:56 PM


  • I figured it out.  I looked in the Microsoft.Data.Tools.Schema.SqlTasks.targets file and found where SqlTargetPath is being set.  It is only being set to the TargetDir if SqlTargetPath is empty.

    <SqlTargetPath Condition=" '$(SqlTargetPath)' == '' ">$(TargetDir)$(SqlTargetFile)</SqlTargetPath>

    Therefore, to fix this I set the property SqlTargetPath in the sqlproj file as shown below.  Right now, I'm setting for local builds and TFS builds.  I still plan on adding a condition so it is only done on the TFS Server. 



        <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>



    I hope it helps someone else out too.


    blog -

    • Marked as answer by MikeDouglasMVP Thursday, November 15, 2012 4:50 AM
    Thursday, November 15, 2012 4:50 AM