I'm having trouble figuring out how I can change the inner text value of an XML node using XmlPoke in Cake. The error I keep getting is Error: Expression must evaluate to a node-set.
My XML looks like this
<?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>
And my build.cake
looks like this
// 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
You'll also need to set the namespace. Like this:
// 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" }
}
});
Also, You might also want to check out Magic Chunks
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With