我无法弄清楚如何使用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
答案 0 :(得分:6)
您还需要设置命名空间。像这样:
// 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