使用 CakeBuild XMLPoke 更改节点的内部文本值
Using CakeBuild XMLPoke change inner text value of node
我无法弄清楚如何在 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
我无法弄清楚如何在 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