2017-09-27 10 views
0

NLog.configはプロダクション用に別のデータベースを指定する必要があります。 this ツールを使用しています。 私のNLog.Configの一部です。web config以外のファイルを変換するreplace要素

<?xml version="1.0" encoding="utf-8"?> 
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
    <targets> 
    <target name="ExceptionLog" type="Database"> 
    <connectionString> 
     ---- Db Connection string for test------- 
    </connectionString> 

プロダクショントランスフォームを作成しましたが、ファイルを変換できません。ここで

は、我々は属性ではなく、全体の要素を変更する必要があり、私は

<?xml version="1.0"?> 
<!-- For more information on using app.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 --> 
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> 

    <parameters value="Db connection for prod" 
      xdt:Transform="Replace" xdt:Locator="XPath(targets/target/connectionString)" /> 
</configuration> 

を持っているものです。

答えて

1

は「nlog」XDT名前空間のエイリアス追加に成功しました:私はここにあるexceptionlogsのような「DebugLogs」のための別のターゲットがあり

<?xml version="1.0"?> 
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform" 
       xmlns:nlog="http://www.nlog-project.org/schemas/NLog.xsd"> 

    <nlog:connectionString xdt:Transform="Replace" 
     xdt:Locator="XPath(/nlog:nlog/nlog:targets/nlog:target/nlog:connectionString)"> 
    ....put-connection-string-here.... 
    </nlog:connectionString> 

</configuration> 
+0

を、どのように私は2番目の文字列を置換します? – SJMan

+1

'XPath(/ nlog:nlog/nlog:targets/nlog:target [@ name = 'ExceptionLog']/nlog:connectionString)'の属性マッチングを使用してターゲットを指定し、別の "Replace"を '@ name = DebugLogs' 。 – Gedrox

関連する問題