title: Pre-Deployment script is not included into publishing script
body: <p>I inherited database project.</p>
  
  <p>it has a lot of create statements for tables and st procedures.
  and for some reason all tables without foreign keys.</p>
  
  <p>So I'm creating foreign keys for tables and when I publish I see that <code>ALTER TABLE</code> is generated
  but data is not clean so it generates an error during the publishing.</p>
  
  <p>I found that I can have Pre-Deployment script (Build Action= PreDeploy)
  so I added there a line to support foreign key</p>
  
  <pre><code>delete from [AccountBalance] where UserId not in (select userid from [user])
  </code></pre>
  
  <p>but when I generate publishing script it is not there.</p>
  
  <p>Why?</p>
  
  <p><strong>Update</strong>
  Sending Project Code</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0"&gt;
    &lt;PropertyGroup&gt;
      &lt;VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''"&gt;10.0&lt;/VisualStudioVersion&gt;
      &lt;SSDTExists Condition="Exists('$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets')"&gt;True&lt;/SSDTExists&gt;
      &lt;VisualStudioVersion Condition="'$(SSDTExists)' == ''"&gt;10.0&lt;/VisualStudioVersion&gt;
      &lt;IncludeSchemaNameInFileName&gt;False&lt;/IncludeSchemaNameInFileName&gt;
      &lt;TargetFrameworkProfile /&gt;
    &lt;/PropertyGroup&gt;
    &lt;Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /&gt;
    &lt;PropertyGroup&gt;
      &lt;Configuration Condition=" '$(Configuration)' == '' "&gt;Debug&lt;/Configuration&gt;
      &lt;Platform Condition=" '$(Platform)' == '' "&gt;AnyCPU&lt;/Platform&gt;
      &lt;SccProvider&gt;SAK&lt;/SccProvider&gt;
      &lt;SccAuxPath&gt;SAK&lt;/SccAuxPath&gt;
      &lt;SccLocalPath&gt;SAK&lt;/SccLocalPath&gt;
      &lt;SccProjectName&gt;SAK&lt;/SccProjectName&gt;
      &lt;UpgradedFromDBP&gt;True&lt;/UpgradedFromDBP&gt;
      &lt;Name&gt;dbpProjectName&lt;/Name&gt;
      &lt;SchemaVersion&gt;2.0&lt;/SchemaVersion&gt;
      &lt;ProjectVersion&gt;4.1&lt;/ProjectVersion&gt;
      &lt;ProjectGuid&gt;{f43cbd44-bbab-48f6-949d-47c9042bb406}&lt;/ProjectGuid&gt;
      &lt;DSP&gt;Microsoft.Data.Tools.Schema.Sql.Sql100DatabaseSchemaProvider&lt;/DSP&gt;
      &lt;OutputType&gt;Database&lt;/OutputType&gt;
      &lt;RootPath&gt;
      &lt;/RootPath&gt;
      &lt;SccProvider&gt;SAK&lt;/SccProvider&gt;
      &lt;SccAuxPath&gt;SAK&lt;/SccAuxPath&gt;
      &lt;SccLocalPath&gt;SAK&lt;/SccLocalPath&gt;
      &lt;SccProjectName&gt;SAK&lt;/SccProjectName&gt;
      &lt;UpgradedFromDBP&gt;True&lt;/UpgradedFromDBP&gt;
      &lt;RootNamespace&gt;dbpProjectName&lt;/RootNamespace&gt;
      &lt;PostUpgradeAddToSCC&gt;;C:\Users\travis\Documents\FR\Projects\Fr\Trunk\Fr.Database\Fr.Database.sqlproj;C:\Users\travis\Documents\FR\Projects\Fr\Trunk\Fr.Database\Connections.txt&lt;/PostUpgradeAddToSCC&gt;
      &lt;SccProvider&gt;
      &lt;/SccProvider&gt;
      &lt;SccAuxPath&gt;
      &lt;/SccAuxPath&gt;
      &lt;SccLocalPath&gt;
      &lt;/SccLocalPath&gt;
      &lt;SccProjectName&gt;
      &lt;/SccProjectName&gt;
      &lt;UpgradedFromDBP&gt;True&lt;/UpgradedFromDBP&gt;
      &lt;AssemblyName&gt;dbpProjectName&lt;/AssemblyName&gt;
      &lt;ModelCollation&gt;1033, CI&lt;/ModelCollation&gt;
      &lt;DefaultFileStructure&gt;BySchemaAndSchemaType&lt;/DefaultFileStructure&gt;
      &lt;DeployToDatabase&gt;True&lt;/DeployToDatabase&gt;
      &lt;TargetFrameworkVersion&gt;v4.5&lt;/TargetFrameworkVersion&gt;
      &lt;TargetLanguage&gt;CS&lt;/TargetLanguage&gt;
      &lt;AppDesignerFolder&gt;Properties&lt;/AppDesignerFolder&gt;
      &lt;SqlServerVerification&gt;False&lt;/SqlServerVerification&gt;
      &lt;TargetDatabaseSet&gt;True&lt;/TargetDatabaseSet&gt;
    &lt;/PropertyGroup&gt;
    &lt;PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "&gt;
      &lt;OutputPath&gt;bin\Release\&lt;/OutputPath&gt;
      &lt;BuildScriptName&gt;$(MSBuildProjectName).sql&lt;/BuildScriptName&gt;
      &lt;TreatWarningsAsErrors&gt;False&lt;/TreatWarningsAsErrors&gt;
      &lt;DebugType&gt;pdbonly&lt;/DebugType&gt;
      &lt;Optimize&gt;true&lt;/Optimize&gt;
      &lt;DefineDebug&gt;false&lt;/DefineDebug&gt;
      &lt;DefineTrace&gt;true&lt;/DefineTrace&gt;
      &lt;ErrorReport&gt;prompt&lt;/ErrorReport&gt;
      &lt;WarningLevel&gt;4&lt;/WarningLevel&gt;
    &lt;/PropertyGroup&gt;
    &lt;PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "&gt;
      &lt;BuildScriptName&gt;$(MSBuildProjectName).sql&lt;/BuildScriptName&gt;
      &lt;TreatWarningsAsErrors&gt;false&lt;/TreatWarningsAsErrors&gt;
      &lt;DebugSymbols&gt;true&lt;/DebugSymbols&gt;
      &lt;DebugType&gt;full&lt;/DebugType&gt;
      &lt;Optimize&gt;false&lt;/Optimize&gt;
      &lt;DefineDebug&gt;true&lt;/DefineDebug&gt;
      &lt;DefineTrace&gt;true&lt;/DefineTrace&gt;
      &lt;ErrorReport&gt;prompt&lt;/ErrorReport&gt;
      &lt;WarningLevel&gt;4&lt;/WarningLevel&gt;
    &lt;/PropertyGroup&gt;
    &lt;!-- VS10 without SP1 will not have VisualStudioVersion set, so do that here --&gt;
    &lt;PropertyGroup /&gt;
    &lt;PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Integration|AnyCPU' "&gt;
      &lt;OutputPath&gt;bin\Debug\&lt;/OutputPath&gt;
      &lt;BuildScriptName&gt;$(MSBuildProjectName).sql&lt;/BuildScriptName&gt;
      &lt;TreatWarningsAsErrors&gt;false&lt;/TreatWarningsAsErrors&gt;
      &lt;DebugSymbols&gt;true&lt;/DebugSymbols&gt;
      &lt;DebugType&gt;full&lt;/DebugType&gt;
      &lt;Optimize&gt;false&lt;/Optimize&gt;
      &lt;DefineDebug&gt;true&lt;/DefineDebug&gt;
      &lt;DefineTrace&gt;true&lt;/DefineTrace&gt;
      &lt;ErrorReport&gt;prompt&lt;/ErrorReport&gt;
      &lt;WarningLevel&gt;4&lt;/WarningLevel&gt;
    &lt;/PropertyGroup&gt;
    &lt;Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets" /&gt;
    &lt;ItemGroup&gt;
      &lt;Folder Include="Properties" /&gt;
      &lt;Folder Include="Cleanup Scripts" /&gt;
      &lt;Folder Include="Pre-Deploy" /&gt;
      &lt;Folder Include="Post-Deploy" /&gt;
    &lt;/ItemGroup&gt;
    &lt;ItemGroup&gt;
      &lt;Folder Include="Change Scripts" /&gt;
      &lt;Folder Include="Create Scripts" /&gt;
      &lt;Folder Include="Data" /&gt;
      &lt;Folder Include="Functions" /&gt;
      &lt;Folder Include="Queries" /&gt;
      &lt;Folder Include="Views" /&gt;
      &lt;Folder Include="Properties" /&gt;
    &lt;/ItemGroup&gt;
    &lt;ItemGroup&gt;
      &lt;Build Include="Create Scripts\AccountBalance.sql" /&gt;
      &lt;Build Include="Create Scripts\AccountTransaction.sql" /&gt;
      &lt;Build Include="Create Scripts\ActivityType.sql" /&gt;
      &lt;Build Include="Create Scripts\Bl.sql" /&gt;
      &lt;Build Include="Create Scripts\Butter.sql" /&gt;
      &lt;Build Include="Create Scripts\ButterStash.sql" /&gt;
      &lt;Build Include="Create Scripts\ButterTransfer.sql" /&gt;
      &lt;Build Include="Create Scripts\City.sql" /&gt;
      &lt;Build Include="Create Scripts\Contact.sql" /&gt;
      &lt;Build Include="Create Scripts\Fan.sql" /&gt;
      &lt;Build Include="Create Scripts\Friend.sql" /&gt;
      &lt;Build Include="Create Scripts\Fr.sql" /&gt;
      &lt;Build Include="Create Scripts\FrLevel.sql" /&gt;
      &lt;Build Include="Create Scripts\FrLevelQuestion.sql" /&gt;
      &lt;Build Include="Create Scripts\FrLevelQuestionResult.sql" /&gt;
      &lt;Build Include="Create Scripts\FrLevelStatus.sql" /&gt;
      &lt;Build Include="Create Scripts\FrMessage.sql" /&gt;
      &lt;Build Include="Create Scripts\FrPlayer.sql" /&gt;
      &lt;Build Include="Create Scripts\FrPlayerStatus.sql" /&gt;
      &lt;Build Include="Create Scripts\FrQuestion.sql" /&gt;
      &lt;Build Include="Create Scripts\FrStatus.sql" /&gt;
      &lt;Build Include="Create Scripts\Invite.sql" /&gt;
      &lt;Build Include="Create Scripts\InviteSource.sql" /&gt;
      &lt;Build Include="Create Scripts\InviteType.sql" /&gt;
      &lt;Build Include="Create Scripts\Lookup.sql" /&gt;
      &lt;Build Include="Create Scripts\Message.sql" /&gt;
      &lt;Build Include="Create Scripts\MessageActivity.sql" /&gt;
      &lt;Build Include="Create Scripts\MessageRecipient.sql" /&gt;
      &lt;Build Include="Create Scripts\MessageType.sql" /&gt;
      &lt;Build Include="Create Scripts\PasswordReset.sql" /&gt;
      &lt;Build Include="Create Scripts\Prize.sql" /&gt;
      &lt;Build Include="Create Scripts\PrizeType.sql" /&gt;
      &lt;Build Include="Create Scripts\TransactionType.sql" /&gt;
      &lt;Build Include="Create Scripts\User.sql" /&gt;
      &lt;Build Include="Create Scripts\UserActivity.sql" /&gt;
      &lt;Build Include="Create Scripts\UserAlternateCountryRequest.sql" /&gt;
      &lt;Build Include="Create Scripts\UserLogin.sql" /&gt;
      &lt;Build Include="Create Scripts\UserMedia.sql" /&gt;
      &lt;Build Include="Create Scripts\UserValidation.sql" /&gt;
      &lt;NotInBuild Include="Data\ActivityType.sql" /&gt;
      &lt;NotInBuild Include="Data\ButterValues.sql" /&gt;
      &lt;NotInBuild Include="Data\CityValues.sql" /&gt;
      &lt;NotInBuild Include="Data\LookupValues.sql" /&gt;
      &lt;NotInBuild Include="Data\User_TestData.sql" /&gt;
      &lt;Build Include="Functions\fn_GetDisplayName.sql" /&gt;
      &lt;Build Include="Functions\fn_ListToTable.sql" /&gt;
      &lt;Build Include="Queries\AccountBalanceGet.sql" /&gt;
      &lt;Build Include="Queries\AccountTransactionCreate.sql" /&gt;
      &lt;Build Include="Queries\AccountTransactionHasCreditPurchase.sql" /&gt;
      &lt;Build Include="Queries\BlCreate.sql" /&gt;
      &lt;Build Include="Queries\BlGetLatest.sql" /&gt;
      &lt;Build Include="Queries\BlsGet.sql" /&gt;
      &lt;Build Include="Queries\ButterGet.sql" /&gt;
      &lt;Build Include="Queries\ButterGetAll.sql" /&gt;
      &lt;Build Include="Queries\ButterMostPopularGet.sql" /&gt;
      &lt;Build Include="Queries\ButterStashCreate.sql" /&gt;
      &lt;Build Include="Queries\ButterStashDelete.sql" /&gt;
      &lt;Build Include="Queries\ButterStashGet.sql" /&gt;
      &lt;Build Include="Queries\ButterTransferCreate.sql" /&gt;
      &lt;Build Include="Queries\ButterTransferGet.sql" /&gt;
      &lt;Build Include="Queries\CitySearchByName.sql" /&gt;
      &lt;Build Include="Queries\FanCreate.sql" /&gt;
      &lt;Build Include="Queries\FanDelete.sql" /&gt;
      &lt;Build Include="Queries\FanSearch.sql" /&gt;
      &lt;Build Include="Queries\FansGet.sql" /&gt;
      &lt;Build Include="Queries\FansOfUserGet.sql" /&gt;
      &lt;Build Include="Queries\FansOfUserSearch.sql" /&gt;
      &lt;Build Include="Queries\FriendCreate.sql" /&gt;
      &lt;Build Include="Queries\FriendDelete.sql" /&gt;
      &lt;Build Include="Queries\FriendSearch.sql" /&gt;
      &lt;Build Include="Queries\FriendSearchByName.sql" /&gt;
      &lt;Build Include="Queries\FriendsGet.sql" /&gt;
      &lt;Build Include="Queries\FrCreate.sql" /&gt;
      &lt;Build Include="Queries\FrDelete.sql" /&gt;
      &lt;Build Include="Queries\FrGet.sql" /&gt;
      &lt;Build Include="Queries\FrGetAll.sql" /&gt;
      &lt;Build Include="Queries\FrGetLevelExpired.sql" /&gt;
      &lt;Build Include="Queries\FrLevelCreate.sql" /&gt;
      &lt;Build Include="Queries\FrLevelGet.sql" /&gt;
      &lt;Build Include="Queries\FrLevelIsComplete.sql" /&gt;
      &lt;Build Include="Queries\FrLevelQuestionClear.sql" /&gt;
      &lt;Build Include="Queries\FrLevelQuestionCreate.sql" /&gt;
      &lt;Build Include="Queries\FrLevelQuestionResultUpsert.sql" /&gt;
      &lt;Build Include="Queries\FrLevelStatusUpdate.sql" /&gt;
      &lt;Build Include="Queries\FrLevelUpdate.sql" /&gt;
      &lt;Build Include="Queries\FrMessageCreate.sql" /&gt;
      &lt;Build Include="Queries\FrMessageDelete.sql" /&gt;
      &lt;Build Include="Queries\FrMessageGet.sql" /&gt;
      &lt;Build Include="Queries\FrMessagesGet.sql" /&gt;
      &lt;Build Include="Queries\FrPlayerAdd.sql" /&gt;
      &lt;Build Include="Queries\FrPlayerRemove.sql" /&gt;
      &lt;Build Include="Queries\FrPlayerUpdate.sql" /&gt;
      &lt;Build Include="Queries\FrQuestionGetAll.sql" /&gt;
      &lt;Build Include="Queries\FrStart.sql" /&gt;
      &lt;Build Include="Queries\FrUpdate.sql" /&gt;
      &lt;Build Include="Queries\FrUpdateFringle.sql" /&gt;
      &lt;Build Include="Queries\InviteCreate.sql" /&gt;
      &lt;Build Include="Queries\InviteDelete.sql" /&gt;
      &lt;Build Include="Queries\InviteDeleteByUserId.sql" /&gt;
      &lt;Build Include="Queries\InviteGet.sql" /&gt;
      &lt;Build Include="Queries\InviteGetAll.sql" /&gt;
      &lt;Build Include="Queries\InviteGetByFrId.sql" /&gt;
      &lt;Build Include="Queries\InviteGetByUserId.sql" /&gt;
      &lt;Build Include="Queries\InviteGetSentAll.sql" /&gt;
      &lt;Build Include="Queries\InviteUpdateAssociateEmailToUserId.sql" /&gt;
      &lt;Build Include="Queries\InviteUpdateInviteStatus.sql" /&gt;
      &lt;Build Include="Queries\InviteUpdateUserId.sql" /&gt;
      &lt;Build Include="Queries\LookupsGet.sql" /&gt;
      &lt;Build Include="Queries\MessageCreate.sql" /&gt;
      &lt;Build Include="Queries\MessageDelete.sql" /&gt;
      &lt;Build Include="Queries\MessageGet.sql" /&gt;
      &lt;Build Include="Queries\MessageRecipientActionUpdate.sql" /&gt;
      &lt;Build Include="Queries\MessageRecipientUpdate.sql" /&gt;
      &lt;Build Include="Queries\MessagesGet.sql" /&gt;
      &lt;Build Include="Queries\MessagesGetSent.sql" /&gt;
      &lt;Build Include="Queries\MessageThreadGet.sql" /&gt;
      &lt;Build Include="Queries\MessageUnreadCountGet.sql" /&gt;
      &lt;Build Include="Queries\PasswordResetCreate.sql" /&gt;
      &lt;Build Include="Queries\PasswordResetDelete.sql" /&gt;
      &lt;Build Include="Queries\PasswordResetGet.sql" /&gt;
      &lt;Build Include="Queries\PrizeGet.sql" /&gt;
      &lt;Build Include="Queries\PrizesGet.sql" /&gt;
      &lt;Build Include="Queries\UserActivityCreate.sql" /&gt;
      &lt;Build Include="Queries\UserActivityForRelatedUsersGet.sql" /&gt;
      &lt;Build Include="Queries\UserActivityGet.sql" /&gt;
      &lt;Build Include="Queries\UserAlternateCountryRequestCreate.sql" /&gt;
      &lt;Build Include="Queries\UserBrowse.sql" /&gt;
      &lt;Build Include="Queries\UserCreate.sql" /&gt;
      &lt;Build Include="Queries\UserFrNameExists.sql" /&gt;
      &lt;Build Include="Queries\UserGet.sql" /&gt;
      &lt;Build Include="Queries\UserGetByEmail.sql" /&gt;
      &lt;Build Include="Queries\UserHasBeenFrer.sql" /&gt;
      &lt;Build Include="Queries\UserLoginInsert.sql" /&gt;
      &lt;Build Include="Queries\UserMediaDelete.sql" /&gt;
      &lt;Build Include="Queries\UserMediaGet.sql" /&gt;
      &lt;Build Include="Queries\UserMediaList.sql" /&gt;
      &lt;Build Include="Queries\UserMediaUpsert.sql" /&gt;
      &lt;Build Include="Queries\UserPasswordUpdate.sql" /&gt;
      &lt;Build Include="Queries\UserProfileGet.sql" /&gt;
      &lt;Build Include="Queries\UserProfileUpdate.sql" /&gt;
      &lt;Build Include="Queries\UserSearch.sql" /&gt;
      &lt;Build Include="Queries\UserUpdate.sql" /&gt;
      &lt;Build Include="Queries\UserValidationGet.sql" /&gt;
      &lt;Build Include="Queries\UserValidationGetByUserId.sql" /&gt;
      &lt;Build Include="Views\UserSummaryView.sql" /&gt;
      &lt;Build Include="Create Scripts\MessageTypeGroup.sql" /&gt;
      &lt;None Include="Data\MessageTypeGroup.sql" /&gt;
      &lt;Build Include="Queries\UserGetByFbId.sql" /&gt;
      &lt;PreDeploy Include="Pre-Deploy\Script.PreDeployment1.sql" /&gt;
    &lt;/ItemGroup&gt;
    &lt;ItemGroup&gt;
      &lt;None Include="Data\Prize.sql" /&gt;
      &lt;None Include="Data\PrizeType.sql" /&gt;
      &lt;None Include="Data\TransactionType.sql" /&gt;
      &lt;None Include="Cleanup Scripts\CleanFrRelatedTables.sql" /&gt;
      &lt;None Include="Data\FrLevelStatus.sql" /&gt;
      &lt;None Include="Data\FrPlayerStatus.sql" /&gt;
      &lt;None Include="Data\FrQuestion.sql" /&gt;
      &lt;None Include="Data\FrStatus.sql" /&gt;
      &lt;None Include="Data\InviteSource.sql" /&gt;
      &lt;None Include="Data\InviteType.sql" /&gt;
      &lt;None Include="Data\MessageActivity.sql" /&gt;
      &lt;None Include="Data\MessageType.sql" /&gt;
      &lt;None Include="Data\FrReminderTypeValues.sql" /&gt;
      &lt;None Include="Fr.DevDatabase.publish.xml" /&gt;
      &lt;None Include="Fr.IntegrationDatabase.publish.xml" /&gt;
      &lt;None Include="Pre-Deploy\Script1.sql" /&gt;
    &lt;/ItemGroup&gt;
    &lt;ItemGroup&gt;
      &lt;Build Include="Create Scripts\Feedback.sql" /&gt;
      &lt;Build Include="Queries\FeedbackCreate.sql" /&gt;
      &lt;Build Include="Create Scripts\FrReminder.sql" /&gt;
      &lt;Build Include="Create Scripts\FrReminderType.sql" /&gt;
      &lt;Build Include="Queries\FrReminderCreate.sql" /&gt;
      &lt;Build Include="Queries\FrReminderUpdate.sql" /&gt;
      &lt;Build Include="Queries\FrReminderDelete.sql" /&gt;
      &lt;Build Include="Queries\FrReminderUpdateUserId.sql" /&gt;
      &lt;Build Include="Queries\FrReminderGetPendingWarnings.sql" /&gt;
      &lt;Build Include="Queries\FrReminderGetPendingExpiries.sql" /&gt;
      &lt;Build Include="Queries\BlsFromFriendsGet.sql" /&gt;
      &lt;Build Include="Create Scripts\Counter.sql" /&gt;
      &lt;Build Include="Queries\CounterGet.sql" /&gt;
      &lt;Build Include="Queries\CounterSet.sql" /&gt;
      &lt;Build Include="Queries\UserActivityHide.sql" /&gt;
      &lt;Build Include="Queries\BlDelete.sql" /&gt;
      &lt;Build Include="Create Scripts\UserBl.sql" /&gt;
      &lt;Build Include="Queries\UserBlGet.sql" /&gt;
      &lt;Build Include="Queries\UserBlCreate.sql" /&gt;
      &lt;Build Include="Queries\UserBlDelete.sql" /&gt;
      &lt;Build Include="Queries\BlGet.sql" /&gt;
      &lt;Build Include="Queries\AccountTransactionGetByFr.sql" /&gt;
    &lt;/ItemGroup&gt;
    &lt;ItemGroup&gt;
      &lt;RefactorLog Include="Fr.Database.refactorlog" /&gt;
    &lt;/ItemGroup&gt;
  &lt;/Project&gt;
  </code></pre>