gpt4 book ai didi

c# - 使用 CakeBuild XMLPoke 更改节点的内部文本值

转载 作者:数据小太阳 更新时间:2023-10-29 02:03:33 27 4
gpt4 key购买 nike

我无法弄清楚如何在 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

最佳答案

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

// 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

关于c# - 使用 CakeBuild XMLPoke 更改节点的内部文本值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43236781/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com