2017-04-05 4 views
2

Ich habe Probleme herauszufinden, wie ich den inneren Textwert eines XML-Knotens mit XmlPoke in Cake ändern kann. Der Fehler, den ich immer halten ist Error: Expression must evaluate to a node-set.Verwenden von CakeBuild XMLPoke Ändern des inneren Textwerts des Knotens

Meine XML wie diese Sie werden auch festlegen müssen den Namespace

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

Und mein build.cake sieht wie folgt aus

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

Antwort

4

aussieht. Wie folgt aus:

// 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" } 
     } 
    }); 

Auch möchten, haben Sie auch Magic Chunks

+0

Dank check it out! Jetzt muss ich nicht auf den/p: OutDir = Pfad gehen, auf den ich mich zubewegte. Und Magic Chunks sieht aus, als wäre es extrem hilfreich. – Stephen

Verwandte Themen