【问题标题】:Using parameters.xml to set parameters on scope different from web.config使用 parameters.xml 在不同于 web.config 的范围内设置参数
【发布时间】:2014-10-07 13:23:03
【问题描述】:

我们正在尝试通过 parameters.xml 将 ApplicationInsights 密钥推送到 ApplicationInsights.config。 该参数不适合所述文件。

我们构建了一个 webdeploy 包,然后发布到不同的环境。所有其他参数均适用于 web.config,并按预期工作。

parameters.xml中的入口:

   <parameter name="InsightInstrumentationKey" description="InsightInstrumentationKey">
      <parameterValidation kind="AllowEmpty" />
      <parameterEntry kind="XmlFile"
                      scope="\\ApplicationInsights.config$"
                      match="/ApplicationInsights/InstrumentationKey/text()" />
   </parameter>

ApplicationInsights.config 文件:

<?xml version="1.0" encoding="utf-8"?>
<ApplicationInsights xmlns="http://schemas.microsoft.com/ApplicationInsights/2013/Settings" schemaVersion="2014-05-30">
  <TelemetryChannel>
    <DeveloperMode>false</DeveloperMode>
  </TelemetryChannel>
  <TelemetryModules>
      [...]
  </TelemetryModules>
  <AccountId></AccountId>
  <InstrumentationKey>HERE GOES THE PARAMETER</InstrumentationKey>
  <ContextInitializers>
      [...]
  </ContextInitializers>
  <TelemetryInitializers>
      [...]
  </TelemetryInitializers>
</ApplicationInsights>

我现在想知道是否有可能有一个与“web.config”不同的 scrope?

【问题讨论】:

    标签: visual-studio webdeploy


    【解决方案1】:

    xmlns 值有问题。试试这个:

    <parameterEntry kind="XmlFile" scope="ApplicationInsights\.config$"match="/*/*[local-name() = 'InstrumentationKey']/text()"/>
    

    【讨论】:

    • 这是我发现的唯一有效的解决方案。
    猜你喜欢
    • 2022-10-07
    • 1970-01-01
    • 2023-04-05
    • 2017-03-01
    • 2015-12-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多