新问题 - >

我有一个需要使用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 /产品/目录/目录/目录/目录[@ Id ='STWebSiteDir'])之前,这不是问题

我尝试使用完整的XPath和更短的//目录[@ 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"/>

我显然遗漏了一些东西。任何人都暗示要去哪里工作?

Vaccano

有帮助吗?

解决方案

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

candle -dVariableName=ValueForVariable

这可能会容易得多。

其他提示

您是否在@(命名空间)中包含了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>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。

Vaccano

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top