【问题标题】:How to change app settings of Web.Config using targets.wpp如何使用 targets.wpp 更改 Web.Config 的应用程序设置
【发布时间】:2015-06-02 16:06:03
【问题描述】:

我创建了一个 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% 

【问题讨论】:

    标签: c# azure msbuild web-config msbuild-wpp


    【解决方案1】:

    可以使用参数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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-01-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多