XmlUpdate 任务不更新我的 XML 文件 [英] XmlUpdate task not updating my XML file
问题描述
我在 MSBuild 脚本中有以下任务:
I have the following task in an MSBuild script:
<XmlUpdate
Namespace="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"
XmlFileName="$(PackageDir)\temp\OddEnds.Testing\OddEnds.Testing.nuspec"
XPath="/package/metadata/version"
Value="%(OddEndsTestingAsmInfo.Version)" />
应该使用程序集版本更新 NuGet 规范文件中的空 version
节点.我的 .nuspec 文件如下所示:
which is supposed to update an empty version
node in a NuGet specification file with the assembly version. My .nuspec file looks like this:
<?xml version="1.0" encoding="utf-8"?>
<package xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http:www.w3.org/2001/XMLSchema-instance">
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<id>OddEnds</id>
<authors>Tomas Lycken</authors>
<!-- Here's the node I want to update -->
<version></version>
<owners>Tomas Lycken</owners>
<description>Odd ends and bits that I might need in any project.</description>
</metadata>
</package>
我相信 XPath 指针 /package/metadata/version
指向正确的节点(因为如果我将其更改为其他内容,它会抱怨找不到节点)但输出显示 0 个节点选择更新.
I believe the XPath pointer /package/metadata/version
points to the right node (since if I change it to something else, it complains about not finding the node) yet the output says 0 node(s) selected for update.
我错过了什么?
推荐答案
您可能需要在 xpath 字符串中包含命名空间.
You may need to include the namespace in your xpath string.
查看这篇博文:http://www.lesnikowski.com/blog/index.php/update-nuspec-version-from-msbuild/
您也可以尝试//*:version.无论命名空间如何,这都会选择所有版本元素.
You can also try //*:version. This will select all version elements regardless of namespace.
这篇关于XmlUpdate 任务不更新我的 XML 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!