在.pubxml中添加自定义dbDacFx提供程序参数

时间:2017-12-14 08:53:34

标签: c# asp.net web-deployment sql-server-data-tools pubxml

我有Visual Studio解决方案,包括WebSSDT项目。我想用WebDeployPackage部署我的网站。我明确地想告诉dbDacFx不要通过已知参数ScriptDatabaseOptions=False部署数据库属性,但我不知道如何在pubxml文件中参数化dbDacFx提供程序。生成的部署配置文件如下所示:

<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>

我正在使用Visual Studio 2015 Enterprise。

1 个答案:

答案 0 :(得分:0)

找到答案。我将参数添加到dacpac源节点,如下所示:

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

您可以在此处找到完整的选项列表:SqlPackage