How to setup a solution that has conditional objects?<p class=MsoNoSpacing style="margin:0in 0in 0pt"><span style="font-size:small;font-family:Calibri">I have a deployment scenario that I am not sure is possible or if so, how to setup as a VSTS DB Edition project.<br/><br/>I want to deploy a database that, depending on a variable (.SQLCMDVARS) may or may not deploy certain objects, or have a different definition.</span></p> <p class=MsoNoSpacing style="margin:0in 0in 0pt"><span style="font-size:small;font-family:Calibri"> </span></p> <p class=MsoNoSpacing style="margin:0in 0in 0pt"><span style="font-size:small;font-family:Calibri">A sample scenario might be:</span></p> <p class=MsoNoSpacing style="margin:0in 0in 0pt"><span style="font-size:small;font-family:Calibri"> </span></p> <p class=MsoNoSpacing style="margin:0in 0in 0pt"><span style="font-size:small;font-family:Calibri">Regardless of the condition, 10 base tables will always be deployed.</span></p> <p class=MsoNoSpacing style="margin:0in 0in 0pt"><span style="font-size:small;font-family:Calibri"> </span></p> <p class=MsoNoSpacing style="margin:0in 0in 0pt"><span style="font-size:small;font-family:Calibri">If Condition1 = true, then deploy additional tables tableA and tableB with 5 columns</span></p> <p class=MsoNoSpacing style="margin:0in 0in 0pt"><span style="font-size:small;font-family:Calibri">If Condition1 = false, then deploy additional tables tableC and tableB with 4 columns</span></p> <p class=MsoNoSpacing style="margin:0in 0in 0pt"><span style="font-size:small;font-family:Calibri">(B being deployed whether true or false but with a different definition)</span></p> <p class=MsoNoSpacing style="margin:0in 0in 0pt"><br/><span style="font-size:small;font-family:Calibri">I initially thought I should:</span></p> <p class=MsoNoSpacing style="margin:0in 0in 0pt"><span style="font-size:small;font-family:Calibri">1) create one database project with the 10 base tables,</span></p> <p class=MsoNoSpacing style="margin:0in 0in 0pt"><span style="font-size:small;font-family:Calibri">2) create another database project with stuff for Condition1 = true</span></p> <p class=MsoNoSpacing style="margin:0in 0in 0pt"><span style="font-size:small;font-family:Calibri">3) create another database project with stuff for Condition1 = false</span></p> <p class=MsoNoSpacing style="margin:0in 0in 0pt"><span style="font-size:small;font-family:Calibri"> </span></p> <p class=MsoNoSpacing style="margin:0in 0in 0pt"><span style="font-size:small;font-family:Calibri">I thought that projects 2 and 3 would be a conditional reference, something I am not sure is possible.</span></p> <p class=MsoNoSpacing style="margin:0in 0in 0pt"><span style="font-size:small;font-family:Calibri"> </span></p> <p class=MsoNoSpacing style="margin:0in 0in 0pt"><span style="font-size:small;font-family:Calibri">The final thought was that if the variable were set true I could do a schema compare against a database that included tableA and and tableB with 5 columns and see not deltas.</span></p> <p class=MsoNoSpacing style="margin:0in 0in 0pt"><span style="font-size:small;font-family:Calibri"> </span></p> <p class=MsoNoSpacing style="margin:0in 0in 0pt"><span style="font-size:small;font-family:Calibri">Is this possible?<br style=""><br style=""></span></p> <p class=MsoNoSpacing style="margin:0in 0in 0pt"><span style="font-size:small;font-family:Calibri">Thanks for reading,</span></p> <p class=MsoNoSpacing style="margin:0in 0in 0pt"><span style="font-size:small;font-family:Calibri">Robert Towne</span></p> <p> </p><hr class="sig">Robert© 2009 Microsoft Corporation. All rights reserved.Tue, 07 Jul 2009 21:24:00 Zffb28b15-3e26-4864-885d-835af16379d8http://social.msdn.microsoft.com/Forums/en-US/vstsdb/thread/ffb28b15-3e26-4864-885d-835af16379d8#ffb28b15-3e26-4864-885d-835af16379d8http://social.msdn.microsoft.com/Forums/en-US/vstsdb/thread/ffb28b15-3e26-4864-885d-835af16379d8#ffb28b15-3e26-4864-885d-835af16379d8sqlserver411http://social.msdn.microsoft.com/Profile/en-US/?user=sqlserver411How to setup a solution that has conditional objects?<p class=MsoNoSpacing style="margin:0in 0in 0pt"><span style="font-size:small;font-family:Calibri">I have a deployment scenario that I am not sure is possible or if so, how to setup as a VSTS DB Edition project.<br/><br/>I want to deploy a database that, depending on a variable (.SQLCMDVARS) may or may not deploy certain objects, or have a different definition.</span></p> <p class=MsoNoSpacing style="margin:0in 0in 0pt"><span style="font-size:small;font-family:Calibri"> </span></p> <p class=MsoNoSpacing style="margin:0in 0in 0pt"><span style="font-size:small;font-family:Calibri">A sample scenario might be:</span></p> <p class=MsoNoSpacing style="margin:0in 0in 0pt"><span style="font-size:small;font-family:Calibri"> </span></p> <p class=MsoNoSpacing style="margin:0in 0in 0pt"><span style="font-size:small;font-family:Calibri">Regardless of the condition, 10 base tables will always be deployed.</span></p> <p class=MsoNoSpacing style="margin:0in 0in 0pt"><span style="font-size:small;font-family:Calibri"> </span></p> <p class=MsoNoSpacing style="margin:0in 0in 0pt"><span style="font-size:small;font-family:Calibri">If Condition1 = true, then deploy additional tables tableA and tableB with 5 columns</span></p> <p class=MsoNoSpacing style="margin:0in 0in 0pt"><span style="font-size:small;font-family:Calibri">If Condition1 = false, then deploy additional tables tableC and tableB with 4 columns</span></p> <p class=MsoNoSpacing style="margin:0in 0in 0pt"><span style="font-size:small;font-family:Calibri">(B being deployed whether true or false but with a different definition)</span></p> <p class=MsoNoSpacing style="margin:0in 0in 0pt"><br/><span style="font-size:small;font-family:Calibri">I initially thought I should:</span></p> <p class=MsoNoSpacing style="margin:0in 0in 0pt"><span style="font-size:small;font-family:Calibri">1) create one database project with the 10 base tables,</span></p> <p class=MsoNoSpacing style="margin:0in 0in 0pt"><span style="font-size:small;font-family:Calibri">2) create another database project with stuff for Condition1 = true</span></p> <p class=MsoNoSpacing style="margin:0in 0in 0pt"><span style="font-size:small;font-family:Calibri">3) create another database project with stuff for Condition1 = false</span></p> <p class=MsoNoSpacing style="margin:0in 0in 0pt"><span style="font-size:small;font-family:Calibri"> </span></p> <p class=MsoNoSpacing style="margin:0in 0in 0pt"><span style="font-size:small;font-family:Calibri">I thought that projects 2 and 3 would be a conditional reference, something I am not sure is possible.</span></p> <p class=MsoNoSpacing style="margin:0in 0in 0pt"><span style="font-size:small;font-family:Calibri"> </span></p> <p class=MsoNoSpacing style="margin:0in 0in 0pt"><span style="font-size:small;font-family:Calibri">The final thought was that if the variable were set true I could do a schema compare against a database that included tableA and and tableB with 5 columns and see not deltas.</span></p> <p class=MsoNoSpacing style="margin:0in 0in 0pt"><span style="font-size:small;font-family:Calibri"> </span></p> <p class=MsoNoSpacing style="margin:0in 0in 0pt"><span style="font-size:small;font-family:Calibri">Is this possible?<br style=""><br style=""></span></p> <p class=MsoNoSpacing style="margin:0in 0in 0pt"><span style="font-size:small;font-family:Calibri">Thanks for reading,</span></p> <p class=MsoNoSpacing style="margin:0in 0in 0pt"><span style="font-size:small;font-family:Calibri">Robert Towne</span></p> <p> </p><hr class="sig">RobertWed, 01 Jul 2009 22:48:22 Z2009-07-01T22:48:22Zhttp://social.msdn.microsoft.com/Forums/en-US/vstsdb/thread/ffb28b15-3e26-4864-885d-835af16379d8#e295f7b7-1fbc-4a5f-b990-2e729c7d54a9http://social.msdn.microsoft.com/Forums/en-US/vstsdb/thread/ffb28b15-3e26-4864-885d-835af16379d8#e295f7b7-1fbc-4a5f-b990-2e729c7d54a9Gert Drapershttp://social.msdn.microsoft.com/Profile/en-US/?user=Gert%20DrapersHow to setup a solution that has conditional objects?<p>The way I read it there are two aspects to your question:<br/><br/>1) Conditionally include an objects as-is<br/>2) Conditionally change the shape of an object<br/><br/>You can included objects in to your projects in 3 ways:<br/>* include files<br/>* partial projects (which is nothing more then a way to group file includes through a file that describes the files to include) <br/>* composite projects<br/><br/>The main difference between partial and composite is that partial you end up with a single deployment, since you are including the source code representation, with composite projects you are including the shape definition only, so you end up with 2 deployments, first the base objects and secondly with the additional objects<br/><br/>Making this conditional is tricky and has to be done at the MSBuild level, and cannot be achieved through SQLCMD variables. SQLCMD variables are nothing more then #define statements that are replaced with the literal value at deployment time. That means they cannnot be used to change the shape or conditionally determine if an object is part of the deployment.<br/><br/>The fact if something is part of the deployment is deteremined by the fact if something is in the build or not. This can be influenced through the &quot;Build Action&quot; on a file, or if you understand MSBuild well enough through conditions which can then be tied to a configuration. All this is manual labor.<br/><br/>If you have two shapes you would have to arrange for this as well at the MSBuild level, where you conditionally include version 1 or 2 of the shape at the file level.<br/><br/>I hope this makes some sense, happy to provide more details.</p><hr class="sig">GertD @ www.DBProj.com Wed, 01 Jul 2009 23:19:21 Z2009-07-01T23:19:21Zhttp://social.msdn.microsoft.com/Forums/en-US/vstsdb/thread/ffb28b15-3e26-4864-885d-835af16379d8#9afeb5d9-a633-4dc6-88d0-89721087b185http://social.msdn.microsoft.com/Forums/en-US/vstsdb/thread/ffb28b15-3e26-4864-885d-835af16379d8#9afeb5d9-a633-4dc6-88d0-89721087b185sqlserver411http://social.msdn.microsoft.com/Profile/en-US/?user=sqlserver411How to setup a solution that has conditional objects?Gert, I think I understand - I'll need to play with a project and can translate your suggestions into something concrete.  If I have more questions I'll reply, and when I knock it out I'll try to post details.<br/><br/>Thank you very much,<br/>Robert<hr class="sig">RobertThu, 02 Jul 2009 17:23:13 Z2009-07-02T17:23:13Z