2

我创建了一个 wpp.targets 文件,它在 azure 中完成所有部署。我想在部署期间将 webconfig 的 appsetting 属性更改为 azure。我在http://sedodream.com/PermaLink,guid,25ddd39e-59de-4e35-becc-de19dcc5e4ea.aspx找到了一个样本,它使用了 pubxml 和 parameters.xml。我想使用 wpp.targets 而不是 pubxml。

  <appSettings>
    <!-- TODO: set this in the azure config -->
    <add key="customer" value="xyz" />
  </appSettings>

需要在部署期间将客户值更新为“客户端”,并且 web.config 文件应反映已部署文件夹中的更改,如下所示

  <appSettings>
    <add key="customer" value="client" />
  </appSettings>

回答

我已经在 msDeploy 中使用ProjectParametersXMLFile

msbuild Api.csproj    /p:ProjectParametersXMLFile="c:\parameter.xml"/p:PublishSettingsFile=%publishFileLocation% 
4

1 回答 1

2

您可以使用参数xml文件

例如

<parameters >
  <parameter name="customer" description="web Job queue name"  defaultValue="sitetest1">
    <parameterEntry kind="XmlFile" 
                    scope="\\web.config$" 
                    match="/configuration/appSettings/add[@key='customer']/@value" />
  </parameter>
  <parameter name="customer" description="web Job queue name"  defaultValue="sitetest">
    <parameterEntry kind="XmlFile"
                    scope="\\app.config$"
                    match="/configuration/appSettings/add[@key='customer']/@value" />
  </parameter>
</parameters>

当您根据您提供的默认值在 azure 中部署时,此文件将更改 appsettings

于 2016-01-08T09:31:07.030 回答