0

新鲜问这个问题->

我有一个需要使用 MSBuild 修改的 WIX 文件。它是这样开始的:

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

我显然错过了一些东西。任何人都暗示去哪里让它工作?

瓦卡诺

4

4 回答 4

3

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

candle -dVariableName=ValueForVariable

那可能会容易得多。

于 2009-05-05T03:39:18.897 回答
1

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

于 2009-05-04T21:27:06.750 回答
1
<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命名空间添加一个前缀,之后就可以了,我已经测试过了。

于 2010-11-24T03:42:29.073 回答
0

好的,所以这是答案:

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。

瓦卡诺

于 2009-05-04T22:06:17.513 回答