使用 parameters.xml 在不同于 web.config 的范围内设置参数

Joh*_*ny5 6 visual-studio webdeploy

我们正在尝试ApplicationInsights.config通过 parameters.xml推送 ApplicationInsights 键。该参数不会按照他的方式访问所述文件。

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

parameters.xml 中的条目:

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

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>
Run Code Online (Sandbox Code Playgroud)

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

LKi*_*iss 4

xmlns 值存在问题。尝试这个:

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