MSBuild (SDC) 和 WIX 中的 XPath

发布于 07-19 07:25 字数 2195 浏览 5 评论 0原文

新问这个问题->

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

度的依靠╰つ2024-07-26 07:25:29

您可以只在预处理器的命令行上定义变量吗?

candle -dVariableName=ValueForVariable

这可能会容易得多。

Can you just define the variables on the command line to the preprocessor?

candle -dVariableName=ValueForVariable

That might be much easier.

花心好男孩2024-07-26 07:25:29

您是否在 @(Namespaces) 中包含了 Wix 默认命名空间?

Have you included the Wix default namespace in @(Namespaces)?

信仰2024-07-26 07:25:29
<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 命名空间添加一个前缀,之后就可以了,我已经测试过了。

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

you should add a prefix for wi namespace too,after that it can ok,i have test it.

你在看孤独的风景2024-07-26 07:25:29

好的,答案如下:

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

瓦卡诺

OK, so here is the answer:

The namespace prefix needed to be missing for the wix part, not just left empty

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

And then you need to add a prefix value to the wix namespace in the file. I used tst.

Vaccano

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文