MSBuild (SDC) 和 WIX 中的 XPath
新问这个问题->
我有一个 WIX 文件,需要使用 MSBuild 进行修改。 它是这样开始的:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:iis="http://schemas.microsoft.com/wix/IIsExtension">
<?--... Various Removed Params ...-->
<Product Id='$(var.ProductCode)'
UpgradeCode='$(var.UpgradeCode)'
Name='$(var.AppName)' Language="1033" Version='$(var.ProductVersion)'
Manufacturer='$(var.Manufacturer)'>
<Package Id='$(var.PackageCode)' InstallerVersion="200"
Compressed="yes" />
<?--... More of the WIX XML file ...-->
<iis:WebApplication Id='STWebApp' Name='MyWebSite' Isolation='medium' />
<?--... Rest of the WIX XML file ...-->
我的问题是 SDC 任务似乎无法引用任何与 WIX 相关的 xml 节点。 例如:
<XmlFile.SetAttribute Path="$(MSBuildProjectDirectory)\TestProduct.wxs"
XPath="//iis:WebApplication" Namespaces="@(Namespaces)"
Name="Name" Value="$(VersionTag)"/>
工作得很好,因为它不使用任何 Wix 节点(只是一个 iis 节点),但如果我使用它的完整 XPath 路径 (/Wix/Product/iis:WebApplication) 任务返回: 找不到资源字符串没有找到 XPath 表达式的匹配
这不是问题,直到我想引用目录节点 (/Wix/Product/Directory/Directory/Directory/Directory[@Id='STWebSiteDir '])
我尝试使用完整的 XPath 和较短的 //Directory[@Id='STWebSiteDir']。 我尝试过单引号和双引号,我尝试将 WIX 命名空间添加到调用中(没有前缀)。
<ItemGroup>
<Namespaces Include="http://schemas.microsoft.com/wix/IIsExtension">
<Prefix>iis</Prefix>
<Uri>http://schemas.microsoft.com/wix/IIsExtension</Uri>
</Namespaces>
<Namespaces Include="http://schemas.microsoft.com/wix/2006/wi">
<Prefix></Prefix>
<Uri>http://schemas.microsoft.com/wix/2006/wi</Uri>
</Namespaces>
</ItemGroup>
我什至尝试仅获取对 /Wix/Product 的引用,甚至失败:
<XmlFile.SetAttribute Path="$(MSBuildProjectDirectory)\TestProduct.wxs"
XPath="/Wix/Product" Namespaces="@(Namespaces)"
Name="Name" Value="MODIFIED"/>
我显然错过了一些东西。 有人知道去哪里让它发挥作用吗?
瓦卡诺
Fresh Asking of this Question->
I have a WIX file that I need to modify using MSBuild. It starts like this:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:iis="http://schemas.microsoft.com/wix/IIsExtension">
<?--... Various Removed Params ...-->
<Product Id='$(var.ProductCode)'
UpgradeCode='$(var.UpgradeCode)'
Name='$(var.AppName)' Language="1033" Version='$(var.ProductVersion)'
Manufacturer='$(var.Manufacturer)'>
<Package Id='$(var.PackageCode)' InstallerVersion="200"
Compressed="yes" />
<?--... More of the WIX XML file ...-->
<iis:WebApplication Id='STWebApp' Name='MyWebSite' Isolation='medium' />
<?--... Rest of the WIX XML file ...-->
My problem is the SDC tasks can't seem to reference any of the xml nodes that are WIX related. For example:
<XmlFile.SetAttribute Path="$(MSBuildProjectDirectory)\TestProduct.wxs"
XPath="//iis:WebApplication" Namespaces="@(Namespaces)"
Name="Name" Value="$(VersionTag)"/>
works just fine because it does not use any Wix nodes (just an iis one), but if I use the full XPath path to it (/Wix/Product/iis:WebApplication) the task returns:
Could not find resource string No matches found for XPath expression
This is not a problem till I want to reference a Directory node (/Wix/Product/Directory/Directory/Directory/Directory[@Id='STWebSiteDir'])
I have tried using the full XPath and the shorter //Directory[@Id='STWebSiteDir']. I have tried single quotes and double quotes, I have tried adding the WIX namespace to the call (with no prefix).
<ItemGroup>
<Namespaces Include="http://schemas.microsoft.com/wix/IIsExtension">
<Prefix>iis</Prefix>
<Uri>http://schemas.microsoft.com/wix/IIsExtension</Uri>
</Namespaces>
<Namespaces Include="http://schemas.microsoft.com/wix/2006/wi">
<Prefix></Prefix>
<Uri>http://schemas.microsoft.com/wix/2006/wi</Uri>
</Namespaces>
</ItemGroup>
I have even tried to just get a reference to /Wix/Product and even that fails:
<XmlFile.SetAttribute Path="$(MSBuildProjectDirectory)\TestProduct.wxs"
XPath="/Wix/Product" Namespaces="@(Namespaces)"
Name="Name" Value="MODIFIED"/>
I am clearly missing something. Anyone with a hint on where to go to get this to work?
Vaccano
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

发布评论
评论(4)
<ItemGroup>
<Namespaces Include="http://schemas.microsoft.com/wix/IIsExtension">
<Prefix>iis</Prefix>
<Uri>http://schemas.microsoft.com/wix/IIsExtension</Uri>
</Namespaces>
<Namespaces Include="http://schemas.microsoft.com/wix/2006/wi">
<Prefix>wis</Prefix>
<Uri>http://schemas.microsoft.com/wix/2006/wi</Uri>
</Namespaces>
</ItemGroup>
你也应该为 wi 命名空间添加一个前缀,之后就可以了,我已经测试过了。
好的,答案如下:
wix 部分需要缺少名称空间前缀,而不仅仅是留空
<ItemGroup>
<Namespaces Include="http://schemas.microsoft.com/wix/IIsExtension">
<Prefix>iis</Prefix>
<Uri>http://schemas.microsoft.com/wix/IIsExtension</Uri>
</Namespaces>
<Namespaces Include="http://schemas.microsoft.com/wix/2006/wi">
<Uri>http://schemas.microsoft.com/wix/2006/wi</Uri>
</Namespaces>
</ItemGroup>
然后您需要向文件中的 wix 名称空间添加一个前缀值。 我用过tst
瓦卡诺
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
您可以只在预处理器的命令行上定义变量吗?
这可能会容易得多。
Can you just define the variables on the command line to the preprocessor?
That might be much easier.