【问题标题】:Using CakeBuild XMLPoke change inner text value of node使用 CakeBuild XMLPoke 更改节点的内部文本值
【发布时间】:2017-04-05 16:29:00
【问题描述】:

我无法弄清楚如何在 Cake 中使用 XmlPoke 更改 XML 节点的内部文本值。我不断收到的错误是Error: Expression must evaluate to a node-set.

我的 XML 看起来像这样

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <WebPublishMethod>FileSystem</WebPublishMethod>
    <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <SiteUrlToLaunchAfterPublish />
    <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
    <ExcludeApp_Data>False</ExcludeApp_Data>
    <publishUrl>This value must be set to your local path</publishUrl>
    <DeleteExistingFiles>False</DeleteExistingFiles>
  </PropertyGroup>
</Project>

而我的build.cake 看起来像这样

// Update the publish path in the pubxml
XmlPoke(publishProfile, "/Project/PropertyGroup/publishUrl/", buildPaths.PublishDirectory);

// The publishProfile is just the location of the XML file
// The buildPaths.PublishDirectory is the value I'm trying to set the inner text to

【问题讨论】:

    标签: c# xml msbuild cakebuild xmlpoke


    【解决方案1】:

    您还需要设置命名空间。像这样:

    // Update the publish path in the pubxml
    XmlPoke(publishProfile,
        "/ns:Project/ns:PropertyGroup/ns:publishUrl",
        buildPaths.PublishDirectory,
        new XmlPokeSettings {
            Namespaces = new Dictionary<string, string> {
                { "ns", "http://schemas.microsoft.com/developer/msbuild/2003" }
            }
        });
    

    另外,您可能还想查看Magic Chunks

    【讨论】:

    • 谢谢!现在我不必走 /p:OutDir= 我开始走向的路径。 Magic Chunks 看起来会很有帮助。
    猜你喜欢
    • 1970-01-01
    • 2012-01-31
    • 2021-01-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多