0

我有一个简单的 xml

<?xml version="1.0"?> 
<rootElement>
 ...
</rootElement>

我正在改变它:

<?xml version="1.0"?> 
<rootElement xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform" xdt:Transform="Remove">
 ...
</rootElement>

然后我在构建过程中得到这个异常:

Exception while replacing configuration-variables in: D:\...\rootelement.config
17:52:12Error
System.Xml.XmlException: Root element is missing.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
17:52:12Error
   at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
17:52:12Error
   at System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r)
17:52:12Error
   at System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r, LoadOptions o)
17:52:12Error
   at System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options)
17:52:12Error
   at Calamari.Integration.ConfigurationVariables.ConfigurationVariablesReplacer.ReadXmlDocument(String configurationFilePath) in Y:\work\14ffc968155e4956\source\Calamari\Integration\ConfigurationVariables\ConfigurationVariablesReplacer.cs:line 62

请注意,我有大约 10 个其他类似的配置文件正在转换没有问题,但这是唯一一个执行“删除”而不是“替换”的配置文件,所以我怀疑这可能是一个问题。

此外,当我在本地预览转换时,它工作正常,所以可能是 Octopus 部署和“Calamari”库的问题

4

1 回答 1

2

XML 文档需要一个根元素,因此转换会导致无效的 XML 文档。

此错误发生在转换后,当 Octopus 尝试替换文件中的变量时。XML 文档无效,因此无法加载。

需要更改转换以生成有效的 XML 文档。

于 2016-05-18T17:41:43.940 回答