Search code examples
c#asp.netweb-deploymentsql-server-data-toolspubxml

Add custom dbDacFx Provider Parameters in .pubxml


I have Visual Studio solution including a Web and SSDT project. I want to deploy my website with WebDeployPackage. I explicit want to tell the dbDacFx not to deploy database properties via the known parameter ScriptDatabaseOptions=False but I don't know how to parameterize the dbDacFx Provider in pubxml file. The generated deployment profile look like following:

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <WebPublishMethod>Package</WebPublishMethod>
    <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <SiteUrlToLaunchAfterPublish />
    <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
    <ExcludeApp_Data>False</ExcludeApp_Data>
    <DesktopBuildPackageLocation>E:\Users\...</DesktopBuildPackageLocation>
    <PackageAsSingleFile>true</PackageAsSingleFile>
    <DeployIisAppPath>mySite/launchSite</DeployIisAppPath>
    <PublishDatabaseSettings>
      <Objects xmlns="">
        <ObjectGroup Name="xxx" Order="1" Enabled="True">
          <Destination Path="ConnectionString" Name="ConnectionStringName" />
          <Object Type="DbDacFx">
            <PreSource Path="ConnectionString" includeData="False" />
            <Source Path="$(IntermediateOutputPath)AutoScripts\xxx_IncrementalSchemaOnly.dacpac" dacpacAction="Deploy" />
          </Object>
          <UpdateFrom Type="Web.Config">
            <Source MatchValue="EntityConnectionString" MatchAttributes="$(UpdateFromConnectionStringAttributes)" />
          </UpdateFrom>
        </ObjectGroup>
      </Objects>
    </PublishDatabaseSettings>
  </PropertyGroup>
  ...
</Project>

I'm using Visual Studio 2015 Enterprise.


Solution

  • Found the answer. I added the parameter to the dacpac source node like following:

    <Source Path="$(IntermediateOutputPath)AutoScripts\xxx_IncrementalSchemaOnly.dacpac" dacpacAction="Deploy" ScriptDatabaseOptions="False" />
    

    You can find a full list of options here: SqlPackage