I have .dacpac project with Script.PostDeployment.sql
:
:r .\SiteType.sql
:r .\Enums.sql
:r .\DebugData.sql
I want to include DebugData.sql
conditionaly, only when i publish with DEBUG
configuration profile selected in visual studio, so i will not have this data included when publish for production.
Is there any way to achieve it?
You can edit the .sqlproj
file used by MSBuild that you use to create your dacpacs.
You can configure the .sqlproj so that certain scripts are included or not depending on what build configuration you are using.
Steps:
Create a project and add a PostDeployment script
Edit the .sqlproj file
Change the ItemGroup containing the PostDeploy script:
<ItemGroup Condition=" '$(Configuration)' == 'Debug' "> <PostDeploy Include="PostDeployment.sql" /> </ItemGroup>
Build in Debug configuration. Extract the dacpac and you will find PostDeployment.sql
Build in Release configuration. Extract the dacpac and you will not find PostDeployment.sql.