【问题标题】:Root element is missing when transforming a simple config with Remove使用 Remove 转换简单配置时缺少根元素
【发布时间】:2016-05-19 01:41:43
【问题描述】:

我有一个简单的 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”库的问题

【问题讨论】:

  • 您到底需要什么?您想要一个完全为空的最终 XML 文件吗?在这种情况下,您可以将原始配置保留为空,并将转换也保留为空。如果所有其他转换都进行了愚蠢的替换,那么我不明白为什么它不起作用。尽管您的问题看起来像是 calamari 中的错误。
  • 我有理由拥有这种结构,我的问题是“预览”工作正常,使用构建任务转换它工作正常,但 Calamari 崩溃。似乎是鱿鱼的错误
  • 我向 Octopus 团队提出了一个错误请求:github.com/OctopusDeploy/Issues/issues/2513

标签: xml octopus-deploy config-transformation


【解决方案1】:

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

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-04-24
    • 2016-05-10
    • 2012-10-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-25
    相关资源
    最近更新 更多