2017-10-05 84 views
0

我的配置文件(file1.config)看着有點像這樣:錯誤章魚部署:找到多個目標元素,但「替換」只變換適用於第一場比賽

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <myelement> 
    oldvalue 
    </myelemetn> 
</configuration> 

我要替換「oldvalue」與「newvalue」。出於這個原因,我創建了一個文件(file1.Development.config)看起來像這樣:

<?xml version="1.0" encoding="utf-8" ?> 
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> 
    <myelement xdt:Transform="Replace"> 
    newvalue 
    </myelemetn> 
</configuration> 

的問題是,當我部署與八達通部署軟件包我收到以下錯誤:

Found multiple target elements, but the 'Replace' Transform only applies to the first match

回答

0

我解決了這個問題通過添加一個xdt:Locator。所以,現在我的轉換文件看起來是這樣的:

<?xml version="1.0" encoding="utf-8" ?> 
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> 
    <myelement xdt:Transform="Replace" xdt:Locator="XPath(/configuration/myelement)"> 
    newvalue 
    </myelemetn> 
</configuration>